<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="portal" uri="/WEB-INF/portal.tld" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <%@ include file="/common/plateform/include/common-base.jsp"%>
  
  <script src="${ctx}/common/plateform/plugins/jQueryUI/jquery-ui.min.js"></script>
  <link href="${ctx}/common/plateform/plugins/jQueryUI/jquery-ui.css" rel="stylesheet">

  
  <title>后台文件编辑</title>
  <style>
  #tabs_checkboxed_colum_content table{border:2px dashed #999;min-width:80px;}
  #tabs_checkboxed_colum_content table tr td{border:2px dashed #999;min-width:80px;}
  #tabs_checkboxed_colum_content table tr td:hover{background-color:#ccc}
  #tabs_checkboxed_colum_content th{border:2px dashed #999;min-width:80px;}
  #tabs_checkboxed_colum_content th:hover{background-color:#ccc}
  </style>
  
</head>
<body>
	<div class="content">
		<div class="row col-lg-12 form-group">
			<button type="button" id="btn-view-1" class="btn btn-primary btn-sm" onclick="viewFile(1)"><i class="fa fa-search-plus"></i> 设计模式</button> 
			<button type="button" id="btn-view-2" class="btn btn-default btn-sm" onclick="viewFile(2)"><i class="fa fa-code"></i> 源码模式</button>
		   	<input type="hidden" name="fileName" id="save-fileName" />
		   	<span class="fx12 f12"><i class="fa fa-info-circle"></i> 当前操作文件路径：<span id="fileStr"></span></span>
		   	<a href="#" id="file_localtion_a" class="btn btn-danger btn-xs" target="_bank"><i class="fa fa-search"></i> 在线预览</a>
		   	<div id="div_other_btn" class="pt5">
		   	</div>
		   	<div class="f12" id="this-span-temp-type"></div>
		</div>
		<div class="row col-lg-12 form-group">
	    	<div id="content-text" class="content" style="border:1px #d73925 dashed;min-height:420px;min-width:100%;">
	   		</div>
	   		<div id="content-text-script"></div>
	    	<div class="col-lg-12 form-group text-center mt5">
		        <button type="button" id="btn-view-2-show" class="btn btn-danger btn-sm" onclick="saveFile()"><i class="fa fa-check"></i> 保存修改</button>
	        </div>
	    </div>
	</div>
<script>
var clickMenu= 'template-edit';
var root_path = '<portal:config varFileName="config" varKey="jsp_path"/>';
var fileRoot = root_path+"${param.pageRoot}";
var fileName = "${param.fileName}.jsp";
var fileRootPathName = "${param.pageRoot}${param.fileName}.jsp";
var thisSysEname = "${param.sysEname}";
$("#fileStr").html(strUtil.showLast(fileRoot)+fileName);
$("#file_localtion_a").attr("href",ctx+"/sendPage${param.pageRoot}${param.fileName}");
//加载js文件
$.getScript("${ctx}/common/plateform/plugins/monaco-editor/min/vs/loader.js");
var editor;
$(function (){
	viewFile(1);
});
function toEditInfo(fileRoot,fileName,id){
	var index_load=layer.msg("正在加载数据。。。");
	$.ajax({type: "post",
		url: common_list_url,data:{"doCode":"doFile","fileRoot":fileRoot,"id":id,"fileName":fileName}, dataType:'json',
		success: function(myData){
			$("#save-fileName").val(myData.fileName);
			
		    require.config({ paths: { 'vs': '${ctx}/common/plateform/plugins/monaco-editor/min/vs' }});
			require.config({
				'vs/nls' : {
					availableLanguages: {
						'*': 'de'
					}
				}
			});
		
			require(['vs/editor/editor.main'], function() {
			   $("#content-text").html('');
				 editor = monaco.editor.create(document.getElementById("content-text"),{
					value: [
		               myData.content				
					].join('\n'),
					language: 'html'
				});
				
			});
			
			layer.close(index_load);

		}
   });
}

function saveFile(){
	var fileRootVal = fileRoot;
	var container=editor.getModel().getValue();
	var index_submit = layer.confirm('您确定要保存内容吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
	, function(){
		layer.close(index_submit);
		var msgIndex = layer.msg("正在保存文件内容...");
		$.ajax({type: "post",
			url: common_submit_url,data:{doCode:"saveFile","fileRoot":fileRootVal,"fileName":$("#save-fileName").val(),"fileText":container,"formToken":"formToken"}, dataType:"json",
			success: function(myData){
				viewFile(2);
				layer.alert(myData.msg);
			}
	   });
	})
}
//加载设计页面
function toPageInfo(){
	var index_load=layer.msg("正在加载页面。。。");
	$.ajaxSetup ({cache: false});
	var filePath = "${param.pageRoot}${param.fileName}";
	var file_url = "${ctx}/sendPage/"+filePath+"?f="+new Date().getTime();
	$("#content-text").load(file_url+" .content-wrapper>",function(resultData){
		$("#content-text-script").html("");
		$result = $(resultData);
       	$result.find("script").appendTo("#content-text-script");//保证子页面的js内容能被引入进来
       	loadDataTempClick();
       	layer.close(index_load);
	});
}

//切换模式
function viewFile(type){
	if(type=="1"){
		toPageInfo();
		$("#btn-view-1").removeClass("btn-default").addClass("btn-primary");
		$("#btn-view-2").removeClass("btn-primary").addClass("btn-default");
		$("#btn-view-2-show").addClass("hidden");
	}else{
		toEditInfo(fileRoot,fileName,"");
		$("#btn-view-1").removeClass("btn-primary").addClass("btn-default");
		$("#btn-view-2").removeClass("btn-default").addClass("btn-primary");
		$("#btn-view-2-show").removeClass("hidden");
		$("#div_other_btn").html("");
	}
	
	
}
</script>

</body>
</html>


<style>
.codeModule{z-index:900;border:2px dashed #999;}
</style>
<script src="${ctx}/common/plateform/plugins/dragsort/jquery.dragsort-0.5.2.min.js"></script>
<script>
var thisCtrObj = null;//当前操作区域
var objNameMap = {};//记录涉及表对象
var thisObjName = null;//记录当前操作对象
var checkedColumMap = {};//记录已选字段对象
var checkedFileGroupMap = {};//记录已选文件上传对象
var thisMainObjName=null,thisMainObjPrimaryKey=null,thisObjNameAll=null;
var thisTempTypeMap = {};//记录当前页面有多少类型表单（可选择四种：searchForm,table,addForm,editForm,viewForm）
var thisCtrTable = null;//当前操作表格
var thisFaCogObj = null;//当前操作控件设置cog对象

//注入模板双击事件
function loadDataTempClick(){
	
	//记录页面主对象及其主键列名
	thisMainObjName=$("#hidden_common_final").find("input[name='mainObjName']").val();
	thisMainObjPrimaryKey=$("#hidden_common_final").find("input[name='mainObjPrimaryKey']").val();
	thisObjNameAll =strUtil.doNull($("#hidden_common_final").find("input[name='objNameAll']").val(),"");

	$("[data-temp-code]").each(function(){
		var thisId = $(this).attr("id");
		if($("[id='"+thisId+"']").length>1){
			layer.alert("有元素id="+thisId+" 重复啦，请检查！");
		}
		$(this).addClass("temp-boxadmin");
		var dataTempType = $(this).attr("data-temp-type");
		thisTempTypeMap[dataTempType]=dataTempType;
		
		//setObjHeight(thisId);
		$(this).mouseover(function(){	//1、绑定鼠标移入事件
			$(this).addClass("fcur").addClass("codeModule");
			$(this).attr("title","双击可以进行设置");
		}).mouseout(function(){	//2、绑定鼠标移出事件
			$(this).removeClass("fcur").removeClass("codeModule");
			$(this).removeAttr("title");
		}).bind("contextmenu", function(e){
	         return false;
	    }).mousedown(function(e){
	    	if (3 == e.which) {
	    		thisCtrTable = $(this);
				openDisplayForm(this);//右键事件，画table区域
	    	}
		}).dblclick(function(){	//3、绑定鼠标双击事件
			if(strUtil.isNull(thisMainObjName)){
				alert("请先设置数据对象");
				showObjNameTable();
				return;
			}
			var obj = $(this);
			$("#div_table_colum_content").height($(window).height()*0.8);//添加了垂直滚动条，所以要控制高度
			thisCtrObj = obj;
			var codeStr = thisObjNameAll;//obj.attr("data-temp-code");
			var cols = 6;//strUtil.doNull(obj.attr("data-temp-cols"),6);
			
			if(!strUtil.isNull(codeStr)){
				var tmepType = obj.attr("data-temp-type");
				//alert("tmepType-->"+tmepType);
				if("fileForm"==tmepType){
					//单独处理文件上传fileForm表单，因为弹出的内容不一样
					var attaType = $(obj).attr("data-file-type");
					$("#modal_file_group").modal("show");
					
					thisCtrObj.find("[data-temp-obj]").each(function(){
						var name = $(this).attr("data-temp-obj");
						var title = $(this).attr("data-temp-title");
						var tagName = $(this).attr("data-type-tag");
						checkedFileGroupMap[title] = eval({"name":name,"title":title,"type":tagName});
					});
					
					//显示对应类型的附件详情列表
					showSysObjAttaListData(attaType);
				}else{
					var codeArry = codeStr.split(",");
					var btnDivHtml = "";
					var objFirstNameKey = "";
					for(var i=0;i<codeArry.length;i++){
						var objectNameTmp = codeArry[i];
						objNameMap[objectNameTmp]=objectNameTmp;
						if(i==0){
							objFirstNameKey=objectNameTmp;
						}
						btnDivHtml+="<button obj-name=\""+objectNameTmp+"\" class=\"btn btn-default btn-xs\" onclick=\"addTabObjColum('"+objectNameTmp+"');\" type=\"button\"> "+objectNameTmp+"对象</button> ";
						
					}
					$("#modal-btn-div").html(btnDivHtml);
					//$("#select_column_size").val(cols);
					//$("#modal_colum_checkbox").modal("show");
					
					$("#modal_colum_checkbox").modal("show");
					
					if("table"!=tmepType){
						$("#btn-dis-dragsort-open").addClass("hidden");
						$("#btn-dis-dragsort-close").addClass("hidden");
						$("#btn-dis-1").removeClass("hidden");
						$("#btn-dis-2").removeClass("hidden");
						$("#tabs_checkboxed_colum_content").html(thisCtrObj.html());
					}else{
						$("#btn-dis-dragsort-open").removeClass("hidden");
						$("#btn-dis-dragsort-close").removeClass("hidden");
						$("#btn-dis-1").addClass("hidden");
						$("#btn-dis-2").addClass("hidden");
						$("#tabs_checkboxed_colum_content").html("");
					}
					
					//$("#tabs_checkboxed_colum_content").find("label").attr("contenteditable",true);//添加支持h5的可编辑文本属性
					//$("#tabs_checkboxed_colum_content").find("label").addClass("form-control-static");//给label添加class
					//$("#tabs_checkboxed_colum_content").find("label").parent().addClass("text-right");//给label的父td添加class
					addGroupDragTools("tabs_checkboxed_colum_content");
					
					getTabObjHistoryMap();//解析加载页面已经存在区域，转json格式map对象
					addTabObjColum(objFirstNameKey);//默认加载第一个表对象的字段
				}
			}
		});	
	});
	
	//给btn按钮世间，特殊操作按钮绑定双击事件控制
	$("[data-temp-event]").each(function(){
		addBtnOpenEvent(this);
	});
	
	
	//设置其他操作按钮：对象，审核，删除等。
	addBtnOtherOptSet();
	
	var thisSpanTempTypeHtml = "";
	for(var s in thisTempTypeMap){
		thisSpanTempTypeHtml+=s+",";
	}
	if(!strUtil.isNull(thisSpanTempTypeHtml)){
		thisSpanTempTypeHtml=thisSpanTempTypeHtml.substring(0,thisSpanTempTypeHtml.length-1);
		$("#this-span-temp-type").html("<span color='fx3'>当前页涵盖表单操作类型："+thisSpanTempTypeHtml+"</span>");
	}
	
}

//添加双击弹出设置pageName,formName等参数窗口
function addBtnOpenEvent(obj){
	var btnEventVal = $(obj).attr("data-temp-event");
	if(btnEventVal.indexOf("search")>-1){
		$(obj).html("<i class='fa fa-cog'></i> 设置查询参数");
	}else if(btnEventVal.indexOf("add")>-1){
		$(obj).html("<i class='fa fa-cog'></i> 设置增加参数");
	}else if(btnEventVal.indexOf("edit")>-1){
		$(obj).html("<i class='fa fa-cog'></i> 设置修改参数");
	}
	
	$(obj).removeAttr("onclick");//暂时移除原本默认事件
	$(obj).removeClass("btn-success").removeClass("btn-warning").removeClass("btn-danger");
	$(obj).mouseover(function(){	//1、绑定鼠标移入事件
		$(obj).addClass("fcur").addClass("codeModule");
		$(obj).attr("title","双击可以进行设置");
	}).mouseout(function(){	//2、绑定鼠标移出事件
		$(obj).removeClass("fcur").removeClass("codeModule");
		$(obj).removeAttr("title");
	}).dblclick(function(){
        if(strUtil.isNull(thisMainObjName)){
            alert("请先设置数据对象");
            showObjNameTable();
            return;
        }
		thisCtrObj = $(obj);
		var divObjId = $(obj).attr("data-temp-event");
		var btnLocationVal = $(obj).attr("data-temp-location");
		$("#modal_event_target_set").modal("show");
		var pageNameDefVal = $("#"+divObjId).find("input[name='pageName']").val();
		var formNameDefVal = $("#"+divObjId).find("input[name='formName']").val();
		var locationVal = $("#"+divObjId).find("input[name='location']").val();
		if(strUtil.isNull(pageNameDefVal)){
			pageNameDefVal = $("#searchForm_hidden").find("input[name='pageName']").val();
		}
		
		//var orderByDefVal = $("#"+divObjId).find("input[name='orderBy']").val();
		$("#div_event_target_modal_content").find("input[name='input-formId']").val(divObjId);
		$("#div_event_target_modal_content").find("input[name='input-formName']").val(formNameDefVal);
		$("#div_event_target_modal_content").find("input[name='input-pageName']").val(pageNameDefVal);
		$("#div_event_target_modal_content").find("input[name='input-location']").val(locationVal);
		var boxAuditTypeObj = $("#div_event_target_modal_content").find("input[name='input-auditType']");
		
		if(divObjId.indexOf("add")>-1 || divObjId.indexOf("edit")>-1  || divObjId.indexOf("audit")>-1 ){
			boxAuditTypeObj.attr("readonly",false);	
			var auditTypeVal = "";
			var auditTypeObj = $("#"+divObjId).find("input[name='auditType']");
			if(auditTypeObj && !strUtil.isNull(auditTypeObj.val())){
				auditTypeVal=auditTypeObj.val();
				boxAuditTypeObj.val(auditTypeVal);
				$(".auditForm").find("select[name='startAudit']").val("T");
			}else{
				$(".auditForm").find("select[name='startAudit']").val("F");
			}
			$(".auditForm").removeClass("hidden");
		}else{
			boxAuditTypeObj.val("");
			boxAuditTypeObj.attr("readonly",true);
			$(".auditForm").addClass("hidden");
			$(".auditForm").find("select[name='startAudit']").val("F");
			$(".auditForm").find("input[name='input-auditType']").val("");
		}
		//iusForm,locationForm
		if(divObjId.indexOf("add")>-1 || divObjId.indexOf("edit")>-1 || divObjId.indexOf("view")>-1){
			$(".locationForm").removeClass("hidden");
		}else{
			$(".locationForm").addClass("hidden");
		}
		
		//$("#div_event_target_modal_content").find("input[name='input-orderBy']").val(orderByDefVal);
		
		//alert(divObjId);
	});
}
//设置其他操作按钮：对象，审核，删除等。
function addBtnOtherOptSet(){
	//操作对象
	var btnObjOptHtml = " <button onclick=\"showObjNameTable();\" class=\"btn btn-primary btn-xs\" type=\"button\"><i class=\"fa fa-cog\"></i> 设置数据对象 "+thisObjNameAll+"</button>";
	
	//设置viewForm查看表单的参数
	if($("#viewForm_hidden").length>0 && "undefined"!=$("#viewForm_hidden").html()){
		btnObjOptHtml+= " <button onclick=\"addBtnOpenEvent(this);\" data-temp-location=\"true\" data-temp-event=\"viewForm_hidden\" class=\"btn btn-primary btn-xs\" type=\"button\"><i class=\"fa fa-cog\"></i> 设置查看参数</button>";
	}
	
	//设置editForm查看表单的参数
	if($("#editForm_hidden").length>0 && "undefined"!=$("#editForm_hidden").html()){
		btnObjOptHtml+= " <button onclick=\"addBtnOpenEvent(this);\" data-temp-location=\"true\"  data-temp-event=\"editForm_hidden\" class=\"btn btn-primary btn-xs\" type=\"button\"><i class=\"fa fa-cog\"></i> 设置修改参数</button>";
	}
	
	//设置delForm删除表单的参数
	if($("#delForm_hidden").length>0 && "undefined"!=$("#delForm_hidden").html()){
		btnObjOptHtml+= " <button onclick=\"addBtnOpenEvent(this);\" data-temp-event=\"delForm_hidden\" class=\"btn btn-primary btn-xs\" type=\"button\"><i class=\"fa fa-cog\"></i> 设置删除参数</button>";
	}
	
	//	btnObjTable+= " <button onclick=\"addBtnOpenEvent(this);\" title=\"双击可以进行设置\" data-temp-event=\"auditForm_hidden\" class=\"btn btn-xs fcur codeModule\" type=\"button\"><i class=\"fa fa-cog\"></i> 设置审核参数</button>";
	$("#div_other_btn").html(btnObjOptHtml);
	
}
//设置元素高度
function setObjHeight(objId){
	var defHeight = "120";
	if($("#"+objId).height()>defHeight) {
		defHeight = $("#"+objId).height();
	}
	$("#"+objId).addClass("temp-boxadmin");
	//$("#"+objId).css("height",defHeight);
}

//获取页面已经存在的元素列
function getTabObjHistoryMap(){
	//2、获取页面已经存在的元素存储map，方便匹配 
	checkedColumMap = {};
	var tmepType = thisCtrObj.attr("data-temp-type");
	if("viewForm"==tmepType){
		//特殊情况：当单独双击操作viewForm情况时，利用此解析原本页面内容。
		thisCtrObj.find("[data-name]").each(function(){
			var objStr = $(this).attr("data-name");
			var objName = objStr.split(".")[0];
			var colum = objStr.split(".")[1];
			var tagName = strUtil.doNull($(this).attr("data-type-tag"),"input");
			var title = $(this).parent().find("label").text();
			if(!strUtil.isNull(title))title=title.substring(0,title.length-1);
			var dataValid = "false";
			var dataReleVal=new Array();//设计viewForm时，三级联动字段数组暂时不支持，多选择一次吧
			var dataDefVal = "";
			var mapKey = objStr;
			var dataColVal=strUtil.doNull($(this).parent().attr("data-col-val"),6);//设置的col-lg-x值
			var dataDictCode= strUtil.doNull($(this).attr("data-dict-code"),"");
			var dataDictCate= strUtil.doNull($(this).attr("data-dict-cate"),"");
			var dataColmun=strUtil.doNull($(this).attr("data-colmun"),"");
			var dataCondition=strUtil.doNull($(this).attr("data-condition"),"");
			var dymicPageName=strUtil.doNull($(this).attr("data-page-name"),"");
			var dymicFormName=strUtil.doNull($(this).attr("data-form-name"),"");
			var dymicDataObjName=strUtil.doNull($(this).attr("data-obj-name"),"");
			checkedColumMap[mapKey] = eval({"objName":objName,"colum":colum,"name":objStr,"title":title,"dataValid":dataValid,
				"type":tagName,"dataDictCode":dataDictCode,"dataDictCate":dataDictCate,"dataColmun":dataColmun,"dataReleVal":dataReleVal,
				"dataDefVal":dataDefVal,"dataColVal":dataColVal,"dataCondition":"","dymicPageName":dymicPageName,"dymicFormName":dymicFormName,"dymicDataObjName":dymicDataObjName});
		});
	}else{
		thisCtrObj.find("[data-temp-obj]").each(function(){
			var objStr = $(this).attr("data-temp-obj");
			var objName = objStr.split(".")[0];
			var colum = objStr.split(".")[1];
			var tagName = $(this)[0].tagName.toLowerCase();
			var title = $(this).attr("data-temp-title");
			var dataValid = strUtil.doNull($(this).attr("data-bv-notempty"),"false");
			//alert(title+"-->"+$(this).attr("data-bv-notempty")+",dataValid="+dataValid);
			var dataReleVal=new Array();//三级联动字段数组
			var dataDefVal = "";
			var dataColVal=$(this).parent().attr("data-col-val");//设置的col-lg-x值
			if(strUtil.isNull(dataColVal)){//如果未定义，在上推一层
				dataColVal=$(this).parent().parent().attr("data-col-val");
			}
			dataColVal = strUtil.doNull(dataColVal,6);
			var mapKey = objStr;
			if(tagName=="th"){
				title = $(this).text();
			}
			
			if($(this).attr("data-type-tag")){
				tagName = $(this).attr("data-type-tag");
			}
			//数据字典类型下拉框，单选框等
			var dataDictCode= "",dataDictCate="",dataColmun="",dataCondition="",dymicPageName="",dymicFormName="",dymicDataObjName="";
			if(tagName=="select" || tagName=="radio" || tagName=="checkbox" || tagName=="selectMultiple"){
				dataDictCode = $(this).attr("data-dict-code");
				dataDictCate = $(this).attr("data-dict-cate");
				dataColmun = $(this).attr("data-colmun");
				
				dataCondition=strUtil.doNull($(this).attr("data-condition"),"");
				dymicPageName=strUtil.doNull($(this).attr("data-page-name"),"");
				dymicFormName=strUtil.doNull($(this).attr("data-form-name"),"");
				dymicDataObjName=strUtil.doNull($(this).attr("data-obj-name"),"");
			}else if(tagName=="rele"){
				dataReleVal[0]=$(this).find(".prov").attr("name");
				dataReleVal[1] = $(this).find(".city").attr("name");
				dataReleVal[2] = $(this).find(".dist").attr("name");
				dataDictCate = $(this).attr("data-rele-code");
				dataColVal = $(this).attr("data-col-val");
			}else if(tagName=="hidden"){
				dataDefVal = $(this).val();
			} 
			checkedColumMap[mapKey] = eval({"objName":objName,"colum":colum,"name":objStr,"title":title,"dataValid":dataValid,
				"type":tagName,"dataDictCode":dataDictCode,"dataDictCate":dataDictCate,"dataColmun":dataColmun,"dataReleVal":dataReleVal,
				"dataDefVal":dataDefVal,"dataColVal":dataColVal,"dataCondition":"","dymicPageName":dymicPageName,"dymicFormName":dymicFormName,"dymicDataObjName":dymicDataObjName});
		});
	}
}

//点击button按钮加载指定表中的字段
function addTabObjColum(objName){
	thisObjName = objName;
	var tempType = thisCtrObj.attr("data-temp-type");
	var isEntity="";
	if("table"==tempType || "searchForm"==tempType){
		isEntity="T";
	}
	$("#modal_colum_checkbox_title").text(objName);

	//1、控制对象按钮选中状态
	$("#modal-btn-div").find("button").each(function(){
		if($(this).attr("obj-name")==objName){
			$(this).removeClass("btn-default").addClass("btn-primary");
		}else{
			$(this).removeClass("btn-primary").addClass("btn-default");
		}
	});
	
	var tabContentHtml="";
	var tabTobjContent = $("#tabs_checkbox_content");
	var index_load = layer.msg("数据正在加载中。。。", {shade: false,offset: '220px'});
	var sortDataParm = {"modelTypes":"s_sortInfo,s_metadata","sortInfo.sortId":"[metadata.sortId]",
			"sortInfo.w_objName":objName,"metadata.w_reserved2":isEntity,
			//"orderBy":"metadata.data_attr asc",
			"f":new Date().getTime()};
	$.get(common_list_url, sortDataParm,function(myData){
		layer.close(index_load);
    	myData.objName=thisObjName;
    	myData.tempType = tempType;
    	tabTobjContent.html(baidu.template("tabs_checkbox_content-template",eval(myData)));
    	if(tempType!="addForm" && tempType!="editForm"){
    		//不是addForm,editForm表单类型的操作，禁用验证必填项input:checkbox的选择
    		tabTobjContent.find("input:checkbox[name='checkbox_dataValid']").attr("disabled",true);
    	}
    	//2、勾选已经存在的行数、复选框、值等
		tabTobjContent.find("tr").each(function(){
			var keyName = $(this).attr("name");
			if(checkedColumMap[keyName]){
				var objMap = checkedColumMap[keyName];
				var tagType = objMap.type;
				var dataDefVal = objMap.dataDefVal;
				$(this).addClass("bg-danger");
				
				var dataValid = strUtil.doNull(objMap.dataValid,"false");
				$(this).find("input:checkbox[name='checkbox_dataValid']").prop("checked",(dataValid=="true")?true:false);
				$(this).find("input:checkbox[name='checkbox_objname']").prop("checked",true);
				$(this).find("input[name='input_columTitle']").val(objMap.title);
				$(this).find("select[name='select_columType']").val(tagType);
				var metadataId = $(this).attr("metadata-id");
				var metadataRestrict = $(this).attr("metadata-restrict");//1:主键，3：可空字段
				if(tagType=="select" || tagType=="radio"  || tagType=="checkbox" || tagType=="selectMultiple"){
					$("#div_req_"+metadataId).show();
					$("#div_select_dict_"+metadataId).show();
					var dataDictCode= objMap.dataDictCode;
					var dataDictCate=objMap.dataDictCate;
					var dataColmun=objMap.dataColmun;
					var dataCondition=objMap.dataCondition;
					var dymicPageName=objMap.dymicPageName;
					var dymicFormName=objMap.dymicFormName;
					var dymicDataObjName = objMap.dymicDataObjName;
					$(this).next().find("select[name='select_req_type']").val(dataDictCode);
					$(this).next().find("select[name='select_req_type']").attr("disabled",false);
					
					$(this).next().find("input[name='input_req_typecode']").val(dataDictCate);
					$(this).next().find("input[name='input_resColmun']").val(dataColmun);
					$(this).next().find("input[name='input_resCondition']").val(dataCondition);
					$(this).next().find("input[name='input-pageName']").val(dymicPageName);
					$(this).next().find("input[name='input-formName']").val(dymicFormName);
					$(this).next().find("input[name='input-objName']").val(dymicDataObjName);
					
					if("dymicSql"==dataDictCode){
						$("#div_resColmun_"+metadataId).show();
						$("#div_iusparams_"+metadataId).show();
						$("#input_req_typecode_"+metadataId).hide();
						$(this).next().find("input[name='input_resColmun']").removeAttr("disabled");
					}else{
						$("#div_resColmun_"+metadataId).hide();
						$("#div_iusparams_"+metadataId).hide();
						$("#input_req_typecode_"+metadataId).show();
					}
				}else if(tagType=="rele"){
					$("#div_req_"+metadataId).show();
					$("#div_select_dict_"+metadataId).show();
					$("#div_rele_select_"+metadataId).show();
                    $("#div_resColmun_"+metadataId).hide();
                    $("#div_iusparams_"+metadataId).hide();
					var dataDictCate=objMap.dataDictCate;
					$(this).next().find("select[name='select_req_type']").val("dictItemList");
					$(this).next().find("select[name='select_req_type']").attr("disabled",true);
					$(this).next().find("input[name='input_req_typecode']").val(dataDictCate);
					var dataReleVal = objMap.dataReleVal;
					$(this).next().find("input[name='input_rele_first']").val(strUtil.lastStr(dataReleVal[0],"."));
					$(this).next().find("input[name='input_rele_second']").val(strUtil.lastStr(dataReleVal[1],"."));
					$(this).next().find("input[name='input_rele_third']").val(strUtil.lastStr(dataReleVal[2],"."));
				}else if(tagType=="hidden"){
					if("1"!=metadataRestrict){
						//不是主键才显示						
						$("#div_req_"+metadataId).show();
						$("#div_hidden_field_def_"+metadataId).show();
						$("#div_hidden_field_def_"+metadataId).find("input[name='input_hidden_field_def']").val(dataDefVal);
					}
					$(this).next().find("input[name='input_req_typecode']").val(dataDefVal);
				}
			}
		});   	
    	
	
	},"json");
	
	//3、如果map不为空，则遍历checkedColumMap
	//alert(checkedColumMap+"=="+Object.keys(checkedColumMap).length);
	
	if("table"==tempType){
		if(Object.keys(checkedColumMap).length>0){
			showColumCheckedData("");
		}
	}
	
	
}
//选中字段，设置背景颜色
function checkColumAttr(obj){
	var objTr = $(obj).parent().parent().parent().parent();
	var colum = $(obj).attr("colum");
	var mapKey = thisObjName+"."+colum;
	if(colum && $(obj).is(':checked')){
		var columTypeObj = objTr.find("select[name='select_columType']");
		if(strUtil.isNull(columTypeObj.val())){
			layer.tips("请先选择此字段显示类型！","#"+columTypeObj.attr("id"),{tips:3});
			$(obj).prop("checked", false);
			return;
		}
		var columTitle = $(obj).attr("colum-title");//objTr.find("input[name='input_columTitle']").val();
		var dataValid = "false";
		var dataValidInput = objTr.find("input[name='checkbox_dataValid']");
		if($(dataValidInput).is(':checked')){
			dataValid = "true";
		}
		var dataDefVal="",dymicPageName="",dymicFormName="",dymicDataObjName="";
		var dataDictCode = "",dataDictCate="",dataColmun = "",dataCondition="",dataReleVal=new Array();//三级联动字段数组
		var columTypeObjVal = columTypeObj.val();
		if(columTypeObjVal=="select" || columTypeObjVal=="radio" || columTypeObjVal=="checkbox" || columTypeObjVal=="rele" || columTypeObjVal=="selectMultiple"){
			var reqTypeVal = objTr.next().find("select[name='select_req_type']").val();
			var reqTypeCodeObj = objTr.next().find("input[name='input_req_typecode']");
			
			if(columTypeObj.val()=="rele"){
				var releObj1 = objTr.next().find("input[name='input_rele_first']");
				if(strUtil.isNull(releObj1.val())){
					layer.tips("请先填写一级字段！","#"+releObj1.attr("id"),{tips:3});
					$(obj).prop("checked", false);
					return;
				}
				dataReleVal[0]=thisObjName+"."+releObj1.val();
				//dataReleSelectVal+=releObj1.val()+",";
				var releObj2 = objTr.next().find("input[name='input_rele_second']");
				if(strUtil.isNull(releObj2.val())){
					layer.tips("请先填写二级字段！","#"+releObj2.attr("id"),{tips:3});
					$(obj).prop("checked", false);
					return;
				}
				dataReleVal[1]=thisObjName+"."+releObj2.val();
				//dataReleSelectVal+=releObj1.val()+",";
				var releObj3 = objTr.next().find("input[name='input_rele_third']");
				if(strUtil.isNull(releObj3.val())){
					layer.tips("请先填写三级字段！","#"+releObj3.attr("id"),{tips:3});
					$(obj).prop("checked", false);
					return;
				}
				dataReleVal[2]=thisObjName+"."+releObj3.val();
				//dataReleSelectVal+=releObj1.val()+",";
				//dataReleSelectVal=dataReleSelectVal.substring(0,dataReleSelectVal.length-1);
			}
			dataDictCode = reqTypeVal;
			dataDictCate = reqTypeCodeObj.val();
			if(reqTypeVal=="dymicSql"){
				var dataColmunObj = objTr.next().find("input[name='input_resColmun']");
				var dataConditionObj = objTr.next().find("input[name='input_resCondition']");
				if(strUtil.isNull(dataColmunObj.val())){
					layer.tips("请先填写返回参数，注意格式！","#"+dataColmunObj.attr("id"),{tips:3});
					$(obj).prop("checked", false);
					return;
				}
				var reqDymicPageNameObj = objTr.next().find("input[name='input-pageName']");
				var reqDymicFormNameObj = objTr.next().find("input[name='input-formName']");
				if(strUtil.isNull(reqDymicPageNameObj.val())){
					layer.tips("请先选择接口参数！","#"+reqDymicPageNameObj.attr("id"),{tips:3});
					$(obj).prop("checked", false);
					return;
				}
				if(strUtil.isNull(reqDymicFormNameObj.val())){
					layer.tips("请先选择接口参数！","#"+reqDymicFormNameObj.attr("id"),{tips:3});
					$(obj).prop("checked", false);
					return;
				}
				dymicPageName=reqDymicPageNameObj.val();
				dymicFormName=reqDymicFormNameObj.val();
				dymicDataObjName = objTr.next().find("input[name='input-objName']").val();
				dataColmun=dataColmunObj.val();
				dataCondition=strUtil.doNull(dataConditionObj.val(),"");
			}else{
				if(strUtil.isNull(reqTypeCodeObj.val())){
					layer.tips("请先填写数据源标识！","#"+reqTypeCodeObj.attr("id"),{tips:3});
					$(obj).prop("checked", false);
					return;
				}
			}
			//alert(dataDictCode+"---"+dataDictCate+"---"+dataColmun);
		}else if(columTypeObj.val()=="hidden"){
			var hiddenDefObj = objTr.next().find("input[name='input_hidden_field_def']");
			/**if(strUtil.isNull(hiddenDefObj.val())){
				layer.tips("请先填写隐藏域默认值！","#"+hiddenDefObj.attr("id"),{tips:3});
				$(obj).prop("checked", false);
				return;
			}**/
			dataDefVal = strUtil.doNull(hiddenDefObj.val(),"");
		}
		var dataColVal=6;//strUtil.doNull($("#select_column_size").val(),6);
		objTr.addClass("bg-danger");
		
		var rowsColum=new Array();
		rowsColum[0]= eval({"objName":thisObjName,"colum":colum,"name":mapKey,"title":columTitle,"dataValid":dataValid,
			"type":columTypeObj.val(),"dataDictCode":dataDictCode,"dataDictCate":dataDictCate,"dataColmun":dataColmun,"dataReleVal":dataReleVal,
			"dataDefVal":dataDefVal,"dataColVal":dataColVal,"dataCondition":"","dymicPageName":dymicPageName,"dymicFormName":dymicFormName,"dymicDataObjName":dymicDataObjName});
		
		var myData = {};
		myData.total=1;
		var tempType=strUtil.doNull(thisCtrObj.attr("data-temp-type"),"addForm");
		myData.rows=rowsColum;
		myData.tempType = tempType;
		myData.formId = thisCtrObj.attr("data-temp-form-id");
		var showContentHtml = baidu.template("form-group-item-template",eval(myData));
		

		if("table"==tempType){
			$("#tabs_checkboxed_colum_content").dragsort("destroy");
			$("#tabs_checkboxed_colum_content").append(showContentHtml);
			closeDragSort();
		}else{
			objTr.find("td:last-child").html(showContentHtml);
			openDraggable(tempType);
		}
	}else{
		objTr.removeClass("bg-danger");
		tempType = thisCtrObj.attr("data-temp-type");
		delete checkedColumMap[mapKey];//删除map元素
		if("table"==tempType){
			showColumCheckedData("");
		}
	}
	
	

}
//选中colum赋值
function showColumCheckedData(cols){
	
	
	$("#tabs_checkboxed_colum_content").dragsort("destroy");//为了防止多次启用dragsort导致冲突，所以进入此方法就先关闭拖拽效果，如果要启动，在另行启动。

	var contentColumDivId = "tabs_checkboxed_colum_content";
	var len  = Object.keys(checkedColumMap).length;
	if(len>0){
		//closeDrag(contentColumDivId);
		
		var ischange = false;
		if(!strUtil.isNull(cols)){
			ischange = true;
		}
		var myData = {};
		myData.total=len;
		var rowsColum=new Array();
		var i = 0;
		for(var key in checkedColumMap){
			if(ischange){
				checkedColumMap[key].dataColVal=cols;
			}
			rowsColum[i]=checkedColumMap[key];
			i++;
		}
		var tempType=strUtil.doNull(thisCtrObj.attr("data-temp-type"),"addForm");
		myData.rows=rowsColum;
		myData.tempType = tempType;
		myData.formId = thisCtrObj.attr("data-temp-form-id");
		var tempId = "form-preview-template";
		if(tempType=="searchForm" || tempType=="table"){
			tempId = tempType+"-preview-template";
		}
		//调用不同的template模板（form和table)
		var checkboxedHtml = baidu.template(tempId,eval(myData));
		$("#"+contentColumDivId).html(checkboxedHtml);
		
		//openDrag(contentColumDivId);
	}else{
		$("#"+contentColumDivId).html("");
	}
}
function changeColumSize(obj){
	showColumCheckedData($(obj).val());
}
//点击全部选择完成按钮后，开始保存到页面，写入文件中
function checkAllOkAndSave(){
	/**
	var len  = Object.keys(checkedColumMap).length;
	if(len<1){
		layer.alert("请至少选择一个对应字段！");
		return;
	}
	**/
	var index_submit = layer.confirm("您确定要保存内容吗？", {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
	, function(){
		layer.close(index_submit);
		
		var thisOptDivId = thisCtrObj.attr("id");
		var thisOptFormId = thisCtrObj.attr("data-temp-form-id");
		var perviewDivObj = $("#tabs_checkboxed_colum_content");
		var newContentText = "";
		
		//1、移除多余的预览样式、准备内容，填充到页面中
		var tempType = thisCtrObj.attr("data-temp-type");
		
		perviewDivObj.find("td").removeClass("ui-droppable");//移除拖拽class
		clearObject(perviewDivObj);//移除其他元素
		
		if(tempType=="searchForm"){
			perviewDivObj.find(".drag-box").each(function(){
				$(this).removeClass("drag-box");
				$(this).removeAttr("title").removeAttr("style");
			});
			//获取最新html内容
			var searchDivId = thisOptDivId;
			var formId = thisCtrObj.attr("data-temp-form-id");
			
			var searchHiddenContent = "";//添加表单hidden内容
			perviewDivObj.find("input[data-type-tag='hidden']").each(function(){
				searchHiddenContent+="\n\t\t\t\t\t\t\t\t\t\t\t\t"+$(this).prop("outerHTML");
				$(this).parent().remove();
			});
			thisCtrObj.html(perviewDivObj.html());
			
			//保存searchForm区域
			var searchForm_newContentText = "<!--\t\t\t\t-->";
			searchForm_newContentText+="<div id=\""+searchDivId+"\" class=\"form-group\"  data-temp-code=\"true\" data-temp-type=\""+tempType+"\" data-temp-form-id=\""+formId+"\">";
			searchForm_newContentText+="\n"+searchHiddenContent+"\n";
			searchForm_newContentText+="\n\t\t\t\t\t"+perviewDivObj.html();
			searchForm_newContentText+="<!--\n\t\t\t\t--></div>";
			//alert(searchForm_newContentText);
			var result_search = saveFileContent(searchDivId,searchForm_newContentText);
		}else if(tempType=="table"){
			thisCtrObj.html("");
			var thHtml = "";
			//为了对应dataList的baidui-template显示是数据列
			var searchObjCodeStr= thisObjNameAll;

			var tdHidInput="";
            var objPrimKeyArray = thisMainObjPrimaryKey.split(",");//联合主键是多个情况
            for(var k=0;k<objPrimKeyArray.length;k++ ){
                tdHidInput+="<input type=\"hidden\" name=\"input_primaryKey\" obj-name=\""+thisMainObjName+"\" primary=\""+objPrimKeyArray[k]+"\" value=\"<?=strUtil.doNull(rows[i]."+thisMainObjName+"."+objPrimKeyArray[k]+",'')?>\"/>"
            }
			var tdHtml = "\t\t\t\t<td style='display:none;'>"+tdHidInput+"</td>";
			perviewDivObj.find(".drag-box").each(function(){
				$(this).removeClass("drag-box");
				$(this).removeAttr("title").removeAttr("style");
				var temObjName = $(this).attr("data-temp-obj");
				thHtml+="<!--\n\t\t\t\t\t\t\t\t\t\t\t--><th data-temp-obj=\""+temObjName+"\">"+$(this).text()+"</th>";
				tdHtml+="<!--\n\t\t\t\t--><td><?=strUtil.doNull(rows[i]."+temObjName+",'')?></td>";
			});
			thHtml+="<!--\n\t\t\t\t\t\t\t\t\t\t\t--><th>操作</th>";
			thisCtrObj.html(thHtml);
			//保存thHtml数据、写入后台
			//alert(thisOptDivId+" || "+tdHtml);
			var result = saveFileContent(thisOptDivId,thHtml);
			
			//保存tdHtml数据、写入后台【保存template模板定义的列名】
			var thisCtrObjTemplateId = thisCtrObj.attr("data-temp-show");
			//alert(thisCtrObjTemplateId+" || "+tdHtml);
			if(result=="T"){
				saveFileContent(thisCtrObjTemplateId,tdHtml);
			}
		}else{
			//alert(perviewDivObj.html());
			//addForm editForm viewForm
			perviewDivObj.find(".drag-box").each(function(){
				$(this).removeClass("drag-box");
				$(this).removeAttr("title").removeAttr("style");
			});
			
			
			/**
			perviewDivObj.find("td").each(function(){
					$(this).removeClass("ui-droppable");//移除拖拽class
					$(this).find(".drag-tools").remove();//移除拖拽工具条
					if(strUtil.isNull($(this).attr("class")))$(this).removeAttr("class");//移除空class属性
					$(this).children().removeClass("has-feedback");//移除子元素定义has-feedback的class值
					$(this).find("label").removeAttr("contenteditable");//移除空h5的可编辑文本属性
					$(this).find("small").remove();//移除子元素small（是反显事所带的验证）
					$(this).find("i[class='form-control-feedback']").remove();//移除子元素i（是反显事所带的验证）
			});
			**/
			//获取最新html内容
			var checkedHtml = perviewDivObj.html();
			thisCtrObj.html(checkedHtml);
			
		
			//保存addForm区域（双击的data-temp-code配置在add区域或者以此开始的优先走此if）
			if(tempType=="addForm" && $("#"+thisOptDivId).length>0 ){
				var addDivId =thisOptDivId;
				//alert("页面有"+addDivId);
				var result_add = saveAddFormContent(thisCtrObj,addDivId,tempType,thisOptFormId);
				if(result_add=="F"){
					return;
				}
			}
			
			if(!thisTempTypeMap["editForm"] || tempType=="editForm" ){
				//保存editForm区域（双击的data-temp-code配置在edit区域或者以add区域开始，并且页面有edit区域，的优先走此if）
				var editDivId = thisOptDivId.replace("add","edit");
				if( $("#"+editDivId).length>0 ){
					//alert("页面有"+editDivId);
					var result_edit = "F";
					if(tempType=="editForm"){
						//这种情况表示修改表单，也支持双击配置，而是这样配置[<div id="editForm1_content" class="row" data-temp-code="true" data-temp-type="editForm">]
						result_edit = saveEditFormContent(perviewDivObj,editDivId,true,tempType,thisOptFormId);
					}else{
						//这种情况表示，修改表单数据数据的填充依托 addForm，本身不支持双击，只是这样配置[<div id="editForm1_content" class="row">]
						result_edit = saveEditFormContent(perviewDivObj,editDivId,false,"","","");
					}
					
					if(result_add=="F"){
						return;
					}
				}
			}
			
			/**
			if(tempType=="addForm" || tempType=="editForm" ){
				//addForm或者editForm保存才valid验证js区域
				var perviewValidObj = perviewDivObj.find("[data-valid='T']");
				if(perviewValidObj.length>0){
					var valiStrJsonContent = "";
					perviewValidObj.each(function(){
						var keyName = $(this).attr("name");
						if(!keyName) keyName= $(this).attr("data-temp-obj");
						var valiors="notEmpty";
						valiStrJsonContent += "\n\t\t\t\t\""+keyName+"\": {\n\t\t\t\t\tvalidators: {\n\t\t\t\t\t\t"+valiors+": {\n\t\t\t\t\t\t\t message: \""+$(this).attr("data-temp-title")+"不能为空！\"\n\t\t\t\t\t\t }\n\t\t\t\t\t}\n\t\t\t\t},";
					});
					if(!strUtil.isNull(valiStrJsonContent)){
						valiStrJsonContent = valiStrJsonContent.substring(0,valiStrJsonContent.length-1);
						valiStrJsonContent="\t\t\tfields:{"+valiStrJsonContent+"}";
					}
					//alert(valiStrJsonContent);
					var result_valid =saveFileContent("validTemp_content",valiStrJsonContent);
				}
			}
	**/
			if(!thisTempTypeMap["viewForm"] || tempType=="viewForm" ){
				var viewDivId = thisOptDivId.replace("add","view").replace("edit","view");
				if($("#"+viewDivId).length>0 ){
					//alert("页面有"+viewDivId);
					var viewStart = false;
					var result_view = "";
					if(tempType=="viewForm"){
						//这种情况表示修改表单，也支持双击配置，而是这样配置[<div id="editForm1_content" class="row" data-temp-code="true" data-temp-type="editForm">]
						tempType = "viewForm";
						result_view = saveViewFormContent(perviewDivObj,viewDivId,true,tempType,thisOptFormId);
					}else{
						//这种情况表示，修改表单数据数据的填充依托 addForm，本身不支持双击，只是这样配置[<div id="editForm1_content" class="row">]
						result_view = saveViewFormContent(perviewDivObj,viewDivId,false,"","","");
					}
					if(result_view=="F"){
						return;
					}
				}
			}
			
		}
		saveRefresh()
		$("#modal_colum_checkbox").modal("hide");
		
	});
}


//保存addForm类型的表单Content
function saveAddFormContent(perviewDivObj,thisOptDivId,tempType,thisOptFormId){
	var addHiddenContent = "";//添加表单hidden内容
	var addForm_newContentText = "<!--\t\t\t\t\t\t\t\t\t\t\t-->";
	addForm_newContentText+="<div id=\""+thisOptDivId+"\" data-temp-code=\"true\" data-temp-type=\""+tempType+"\" data-temp-form-id=\""+thisOptFormId+"\">";
	perviewDivObj.find("input[data-type-tag='hidden']").each(function(){
		addHiddenContent+="\n\t\t\t\t\t\t\t\t\t\t\t\t"+$(this).prop("outerHTML");
		//$(this).parent().parent().remove();
		$(this).parent().remove();
	});
	addForm_newContentText+="\n"+addHiddenContent+"\n";
	addForm_newContentText+="\n\t\t\t\t\t\t\t\t\t"+perviewDivObj.html();
	addForm_newContentText+="<!--\n\t\t\t\t\t\t\t\t\t\t--></div>";
	//alert(thisOptDivId+"：\n"+addForm_newContentText);
	var result_add = saveFileContent(thisOptDivId,addForm_newContentText);
	return result_add;
}
//保存editForm类型的表单Content
function saveEditFormContent(perviewDivObj,thisOptDivId,editStart,tempType,thisOptFormId){
	var editDivId = thisOptDivId.replace("add","edit");
	var editHiddenContent = "";//修改表单hidden内容
	//alert(perviewDivObj.html());
	perviewDivObj.find("[data-temp-obj]").each(function(){
		var tagName = $(this).attr("data-type-tag");
		var dataName = $(this).attr("data-temp-obj");//$(this).attr("name");
		//alert($(this).prop("outerHTML"));
		if($(this).attr("id")){
			$(this).attr("id",$(this).attr("id").replace("addForm","editForm"));
		}
		if(tagName=="uploadImg"){
			//修改表单图片上传类型的单独处理 data-name
			$(this).find("img").attr("data-name",dataName);
			$(this).find("input").attr("data-name",dataName);
		}else if(tagName=="uploadFile"){
			//修改表单文件上传类型的单独处理 data-name
			$(this).find("[file-btn='true']").text("重新上传");
			$(this).find("[file-a='true']").attr("data-name",dataName);
			$(this).find("[file-a='true']").text("点击查看");
			$(this).find("input").attr("data-name",dataName);
		}else if(tagName=="hidden"){
			$(this).attr("data-name",dataName);//当editForm表单时补充【data-name】
			editHiddenContent+="\n\t\t\t\t\t\t\t\t\t\t\t\t"+$(this).prop("outerHTML");
			//$(this).parent().parent().remove();
			$(this).parent().remove();
		}else if(tagName=="checkbox"){
			$(this).attr("data-name",dataName);//当editForm表单时补充【data-name】
			$(this).parent().find("input[type='hidden'][name='"+dataName+"']").remove();
		}else if(tagName=="rele"){
			$(this).find("select[name]").each(function(){
				$(this).attr("data-name",$(this).attr("name"));
			});
		}else{
			$(this).attr("data-name",dataName);//修改时，给每个元素添加data-name属性
		}
		//单独处理selectMultiple
		if(tagName=="selectMultiple" && $(this).attr("data-multiple-result-id")){
			$(this).attr("data-multiple-result-id",$(this).attr("data-multiple-result-id").replace("addForm","editForm"));
		}
	});
	var editForm_newContentText= "<!--\t\t\t\t-->";
	if(editStart){
		editForm_newContentText+="<div id=\""+editDivId+"\" data-temp-code=\"true\" data-temp-type=\""+tempType+"\" data-temp-form-id=\""+thisOptFormId+"\" >";
	}else{
		editForm_newContentText+="<div id=\""+editDivId+"\">";
	}
	editForm_newContentText+="\n"+editHiddenContent+"\n";
	editForm_newContentText+="\n\t\t\t\t\t"+perviewDivObj.html();
	editForm_newContentText+="<!--\n\t\t\t\t--></div>";
	//alert(editDivId+"：\n"+editForm_newContentText);
	var result_edit =saveFileContent(editDivId,editForm_newContentText);
	return result_edit;
}
//保存viewForm类型的表单Content
function saveViewFormContent(perviewDivObj,thisOptDivId,viewStart,tempType,thisOptFormId){
	//alert(perviewDivObj.html());
	var viewDivId = thisOptDivId.replace("add","view").replace("edit","view");
	perviewDivObj.find("[data-temp-obj]").each(function(){
		$(this).parent().find("label > font").remove();
		if($(this).parent().is(".form-group")){
			$(this).parent().removeClass("form-group").addClass("form-control-static");
		}
		var dataName = $(this).attr("data-temp-obj");//$(this).attr("name");
		var spanObjHtml = "<span data-name=\""+dataName+"\"></span>";//查看时，异常给每个元素，同时在其后添加span data-name
		var tagName = $(this).attr("data-type-tag");
		if(!strUtil.isNull(tagName)){
			if(tagName=="date"){
				$(this).parent().after(spanObjHtml);
				$(this).parent().remove();
			}else if(tagName=="uploadImg"){
				//图片上传类型的单独处理
				spanObjHtml="<img src=\"/images/def.jpg\" data-name=\""+dataName+"\" style=\"width:120px;height:80px;\" data-type-tag=\"uploadImg\" />"
				$(this).after(spanObjHtml);
				$(this).remove();
			}else if(tagName=="uploadFile"){
				//文件上传类型的单独处理 data-name
				spanObjHtml="<a href=\"#\" data-name=\""+dataName+"\" data-type-tag=\"uploadFile\" target=\"_bank\">点击查看</a>"
				$(this).after(spanObjHtml);
				$(this).remove();
			}else if(tagName=="hidden" || tagName=="password"){
				$(this).parent().parent().remove();//查看表单删除hidden，password
			}else if(tagName=="checkbox"){
				$(this).addClass("hidden");
				$(this).attr("data-show-type","view");//避免和修改原因，特殊标识为view
				$(this).attr("id",$(this).attr("id").replace("add","view").replace("edit","view"));
				$(this).parent().find("input[type='hidden'][name='"+dataName+"']").remove();
			}else if(tagName=="rele"){
				//三级联动情况下
				var dataDictCate = $(this).attr("data-rele-code");
                var new_rele_divId = strUtil.doNull($(this).attr("id"),"viewForm").replace("edit","view");
                $(this).attr("id",new_rele_divId);
				spanObjHtml = "<span data-name=\""+$(this).find(".prov").attr("name")+"\" data-dict=\""+dataDictCate+"\" data-rele-type='prov'></span>&nbsp;";
				spanObjHtml +="<span data-name=\""+$(this).find(".city").attr("name")+"\" data-dict=\""+dataDictCate+"\" data-rele-type='city'></span>&nbsp;";
				spanObjHtml +="<span data-name=\""+$(this).find(".dist").attr("name")+"\" data-dict=\""+dataDictCate+"\" data-rele-type='dist'></span>&nbsp;";
				$(this).removeAttr("data-temp-obj rele-first rele-second rele-third rele-first-def rele-second-def rele-third-def data-bv-notempty");
				$(this).find("div").html(spanObjHtml);
			}else if(tagName=="selectMultiple"){
				$(this).parent().parent().parent().remove();//查看表单删除selectMultiple
			}else{
				//select ,radio
				var dataDictCode=$(this).attr("data-dict-code");
				var dataDictCate=$(this).attr("data-dict-cate");
				var dataPageName=$(this).attr("data-page-name");
				var dataFormName=$(this).attr("data-form-name");
				var dataObjName=$(this).attr("data-obj-name");
				var dataCondition=$(this).attr("data-condition");
				var spanObjId = $(this).attr("id").replace("add","view").replace("edit","view");
				spanObjHtml = "<span id=\""+spanObjId+"\" data-dict-cate=\""+dataDictCate+"\"";
				spanObjHtml += " data-dict-code=\""+dataDictCode+"\" data-type-tag=\""+strUtil.doNull($(this).attr("data-type-tag"),'input')+"\" ";
				if(dataDictCode=="dymicSql"){
					var dataColmun = $(this).attr("data-colmun");
					if(!strUtil.isNull(dataDictCate)){
						spanObjHtml += " data-dict-url=\"modelTypes="+dataDictCate+"\" ";
					}else{
						spanObjHtml += " data-page-name=\""+dataPageName+"\"  data-form-name=\""+dataFormName+"\" data-obj-name=\""+dataObjName+"\" data-condition=\""+dataCondition+"\" ";
					}
					spanObjHtml += " data-name=\""+dataName+"\" data-colmun=\""+dataColmun+"\" ";
				}else{
					spanObjHtml += " data-name=\""+dataName+"\" data-dict=\""+dataDictCate+"\" ";
				}
				spanObjHtml +="></span>";
				$(this).after(spanObjHtml);
				$(this).remove();
			}
		}else{
			//input
			$(this).after(spanObjHtml);
			$(this).remove();
		}
	});
	var viewForm_newContentText= "<!--\t\t\t\t-->";
	if(viewStart){
		viewForm_newContentText+="<div id=\""+viewDivId+"\" class=\"row viewForm\" data-temp-code=\"true\" data-temp-type=\""+tempType+"\" data-temp-form-id=\""+thisOptFormId+"\" >";
	}else{
		viewForm_newContentText+="<div id=\""+viewDivId+"\" class=\"row viewForm\">";
	}
	viewForm_newContentText+="\n\t\t\t\t\t"+perviewDivObj.html();
	viewForm_newContentText+="<!--\n\t\t\t\t--></div>";
	//alert(viewDivId+"：\n"+viewForm_newContentText);
	var result_view =saveFileContent(viewDivId,viewForm_newContentText);
	if(result_view=="F"){
		return;
	}
}
//保存文件内容
function saveFileContent(tempId,newContentText){
	var tempPath = fileRootPathName;
	//alert(tempPath);
	//if(true) return "T";
	var dataParam= {"flagType":"T","formToken":"formToken","filePath":tempPath,"code":tempId,"newContent":newContentText};
	var msgIndex = layer.msg("正在保存文件中["+tempId+"]区域的内容...");
	var result = "F";
	$.ajax({
	    type:'post',
	   	url:ctx+"/trans/template/setTemplateParams",
	    data: dataParam,
	    async:false,
	    dataType:"json",
	    success: function(myData){
			$(".modal").each(function() {
			    $(this).modal('hide');
			});
	    	result="T";
	    }
	});	
	return result;
}
function saveRefresh(){
	if(fileRoot.indexOf("webapps")>-1){
		layer.msg("页面重新加载完成！");
		viewFile(1); 
	}else{
		alert("操作完成，请先刷新开发工具");
		viewFile(1); 
	}
}

//选择器设置不同显示类型所要对接的数据。
function setColumParam(o,id){
	var selVal = $(o).val();
	$(o).parent().parent().find("input:checkbox[name='checkbox_dataValid']").attr("disabled",false);//默认可以设置必填项规则
	$("#div_req_"+id).hide();
	$("#div_select_dict_"+id).hide();
	$("#div_resColmun_"+id).hide();
	$("#div_iusparams_"+id).hide();
	$("#div_hidden_field_def_"+id).hide();
	$("#div_rele_select_"+id).hide();
	if(!strUtil.isNull(selVal)){
		if(selVal=="select" || selVal=="selectMultiple"){
			$("#div_req_"+id).show();
			$("#div_select_dict_"+id).show();
			$("#select_req_type_"+id).removeAttr("disabled");
			$("#input_req_typecode_"+id).attr("placeholder","格式如：tdxz科目标识");
		}else if(selVal=="radio" || selVal=="checkbox"){
			$("#div_req_"+id).show();
			$("#select_req_type_"+id).val("dictItemList");
			$("#select_req_type_"+id).attr("disabled",true);
			$("#div_select_dict_"+id).show();
			$(o).parent().parent().find("input:checkbox[name='checkbox_dataValid']").attr("disabled",true);//这两种情况不支持 必填项校验选择
		}else if(selVal=="rele"){
			//三级联动：	如省市区等
			$("#select_req_type_"+id).val("dictItemList");
			$("#div_req_"+id).show();
			$("#div_select_dict_"+id).show();
			$("#div_rele_select_"+id).show();
			$("#input_req_typecode_"+id).attr("placeholder","可填写单词：area，ipc");
		}else if(selVal=="hidden"){
			$("#div_req_"+id).show();
			$("#div_hidden_field_def_"+id).show();//开启设置hidden的默认值文本框
		}
	}
}

//切换选择
function chartDiv(obj){
	var iObj = $(obj).find("i");
	if(iObj.is(".fa-minus")){
		$("#tabs_checkbox_1").removeClass("col-lg-5").addClass("col-lg-1");
		$("#tabs_checkbox_2").removeClass("col-lg-7").addClass("col-lg-10");
	}else{
		$("#tabs_checkbox_1").removeClass("col-lg-1").addClass("col-lg-5");
		$("#tabs_checkbox_2").removeClass("col-lg-10").addClass("col-lg-7");
	}
}

var contextmenuObj = null;
//单独修改每一个元素的跨行列
function changeColumSiginOne(obj){
	if(contextmenuObj){
		var oldColSize = contextmenuObj.attr("data-col-val");
		var newColSize = $(obj).val();
		contextmenuObj.removeClass("col-lg-"+oldColSize).addClass("col-lg-"+newColSize);
		contextmenuObj.attr("data-col-val",newColSize);
	}
}

//设置指定可拖拽元素的右击事件
function setContextmenuColu(id){
	//某元素组织右键点击事件
  /**  $("#"+id).bind("contextmenu", function(){
         return false;
     });
	
	$(".drag-box").mousedown(function(e) {
		//右键为3
		contextmenuObj = $(this);
			if (3 == e.which) {
				var titleText = $(this).attr("data-temp-title");
				if(strUtil.isNull(titleText)){
				titleText = $(this).find("[data-temp-title]").attr("data-temp-title");
			}
			$("#contextmenu_filed_title").text(titleText+"：");
			$("#contextmenu_select").val($(this).attr("data-col-val"));
			$("#modal_contextmenu_set").modal("show");
       	}
	});
	**/
}
//开启拖拽排序
function openDragSort(){
	$("#btn-dis-dragsort-open").prop("disabled",true);
	$("#btn-dis-dragsort-close").prop("disabled",false);
	$("#tabs_checkboxed_colum_content").dragsort({
        dragSelector : ".drag-box",  //可以不用设置，他会根据$("#tableid")的类型来决定是tr还是li
        dragEnd : function(){
        	//alert($(this));
            //console.log($(this));  //拖动完成的回调函数，$(this)当前拖动对象
        },
        scrollSpeed:0,  //默认为5，数值越大拖动的速度越快，为0则拖动时页面不会滚动
    });
}
//关闭拖拽排序
function closeDragSort(){
	$("#btn-dis-dragsort-open").prop("disabled",false);
	$("#btn-dis-dragsort-close").prop("disabled",true);
	$("#tabs_checkboxed_colum_content").dragsort("destroy");
}
//开启拖拽复制
function openDraggable(tempType){
	 //拖拽复制体
     $("#tabs_checkbox_content").find("td").find(".drag-box").draggable({
		   helper:"clone",
		   cursor: "move",
		   start:function(){
		   }
     });
	 //tempType
	 if("table"==tempType){
		//释放后存放的区域
		 $("#tabs_checkboxed_colum_content").droppable({
			   	activeClass: "ui-state-hover",
			   	hoverClass: "ui-state-active",
				drop:function(event,ui){
					//$(this).children().remove();
					var source = ui.draggable.clone();
					$(this).append("<div class='col-lg-3' style='border:1px dashed #999;padding:2px;'>"+source.html()+"</div>");
					//var sourceObjName = $(this).find("[name]").attr("name");
					$(this).find(".drag-tools").find("label").html("<i class='fa fa-trash-o'></i>");
					$(this).find(".drag-tools").find("label").click(function(){
						//alert($(this).parent().parent().html());
						$(this).parent().parent().remove();//移除元素
					});
					
					$(this).mouseenter(function () { 
						$(this).find(".drag-tools").show();
					}); 

					$(this).mouseleave(function () {
						$(this).find(".drag-tools").hide();
					}); 

				}
			});
	 }else{
		//释放后存放的区域
		 $("#tabs_checkboxed_colum_content").find("td").droppable({
			   	activeClass: "ui-state-hover",
			   	hoverClass: "ui-state-active",
				drop:function(event,ui){
					$(this).children().remove();
					var source = ui.draggable.clone();
					$(this).html(source.html());
					//var sourceObjNsame = $(this).find("[name]").attr("name");
                    var toolsConHms="<div class='col-sm-8'><label class='label label-default fcur'>";
                    toolsConHms+="<i class='fa fa-cog'></i>";
                    toolsConHms+="</label></div>";

                    toolsConHms+="<div class='col-sm-4'><label class='label label-default fcur'>";
                    toolsConHms+="<i class='fa fa-trash-o'></i>";
                    toolsConHms+="</label></div>";

					$(this).find(".drag-tools").html(toolsConHms);
					$(this).find(".drag-tools").find("label").find(".fa-trash-o").click(function(){
						//alert($(this).parent().parent().html());
						$(this).parent().parent().parent().parent().html("&nbsp;");//移除元素
					});
					
					$(this).mouseenter(function () { 
						$(this).find(".drag-tools").show();
					}); 

					$(this).mouseleave(function () {
						$(this).find(".drag-tools").hide();
					}); 

				}
			});
	 }
	  
 }
 

//多值（select等类型）选项设置
function changeReqTypeVal(obj,attrId){
	var objVal = $(obj).val();
	var inputReqObj = $("#input_req_typecode_"+attrId);
	var inputResColObj = $("#input_resColmun_"+attrId);
	//var btnResColObj = $("#btn_resColmun_"+attrId);
	
	inputReqObj.val("");
	inputResColObj.val("");
	if(objVal == "dictItemList"){
		inputResColObj.prop("disabled",true);
		inputReqObj.attr("placeholder","格式如：tdxz科目标识");
		inputReqObj.show();
		//btnResColObj.prop("disabled",true);
		$("#div_resColmun_"+attrId).hide();
		$("#div_iusparams_"+attrId).hide();
	}else{
		inputResColObj.prop("disabled",false);
		//inputReqObj.prop("disabled",true);
		inputReqObj.hide();
		//btnResColObj.removeAttr("disabled");
		$("#div_resColmun_"+attrId).show();
		$("#div_iusparams_"+attrId).show();
	}
}

//保存事件，参数设置完成
var rulesname = "";
function saveEventTarget(divId){
	var index_submit = layer.confirm("您确定要保存设置吗？", {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
	, function(){
		layer.close(index_submit);
	
		var divObj = $("#"+divId);
		var pageNameVal = divObj.find("input[name='input-pageName']").val();
		var formNameVal = divObj.find("input[name='input-formName']").val();
		var auditTypeVal = divObj.find("input[name='input-auditType']").val();
		var startAuditVal = divObj.find("select[name='startAudit']").val();
		var locationVal = divObj.find("input[name='input-location']").val();
		
		//var orderByVal = divObj.find("input[name='input-orderBy']").val();
		var thisCtrObjId = thisCtrObj.attr("data-temp-event");
		var ttc = "";
		var hideHtml = "\t\t\t\t\t\t\t\t\t"+ttc+"<div id=\""+thisCtrObjId+"\" style=\"display:none;\">";
		hideHtml+="\n\t\t\t\t\t\t\t\t\t\t"+ttc+"<input type=\"hidden\" name=\"pageName\" value=\""+pageNameVal+"\"/>";
		hideHtml+="\n\t\t\t\t\t\t\t\t\t\t"+ttc+"<input type=\"hidden\" name=\"formName\" value=\""+formNameVal+"\"/>";
		if(startAuditVal=="T"){
			ttc+="\t\t";
			if(strUtil.isNull(auditTypeVal)){
				layer.tips("请填写审核类型！","#input-auditType-id",{tips:3});
				return;
			}
			if(strUtil.isNull(rulesname)){
				layer.tips("所选择接口未配置插件组合，配置后再重新选择！","#input-formName-id",{tips:3});
				return;
			}
			hideHtml+="\n\t\t\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"auditType\" value=\""+auditTypeVal+"\">";
		}
		if(thisCtrObjId.indexOf("edit")>-1){
            var objPrimKeyArray = thisMainObjPrimaryKey.split(",");//支持联合主键是多个情况
            for(var k=0;k<objPrimKeyArray.length;k++ ){
                hideHtml+="\n\t\t\t\t\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\""+thisMainObjName+".w_"+objPrimKeyArray[k]+"\" data-name=\""+thisMainObjName+"."+objPrimKeyArray[k]+"\" class=\""+thisMainObjName+"_"+objPrimKeyArray[k]+" clean\">";
            }
		}
		if(thisCtrObjId.indexOf("search")>-1){
			hideHtml+="\n\t\t\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"orderBy\" value=\""+thisMainObjName+".create_time desc\"/>";
		}
		if(thisCtrObjId.indexOf("viewForm")>-1){
            var objPrimKeyArray = thisMainObjPrimaryKey.split(",");//支持联合主键是多个情况
            for(var k=0;k<objPrimKeyArray.length;k++ ){
                hideHtml+="\n\t\t\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\""+thisMainObjName+".w_"+objPrimKeyArray[k]+"\" value=\"\${param."+objPrimKeyArray[k]+"}\"/>";
            }
		}
		
		if(!strUtil.isNull(locationVal)){
			hideHtml+="\n\t\t\t\t\t\t\t\t\t\t<input type=\"hidden\" name=\"location\" value=\""+locationVal+"\"/>";
		}
		hideHtml+="\n\t\t\t\t\t\t\t\t\t"+ttc+"</div>";
		var tempId = thisCtrObjId;
		//保存IUS隐藏参数内容
		var hidFlag = saveFileContent(tempId,hideHtml);
		
		saveRefresh();
		
	});
}

//弹出选择ius参数框
var loginWin = null;
var pageNameTempObj,formNameTempObj,objNameTempObj;
//var orderByObj;
function toOpenIus(divId){
	var divObj = $("#"+divId);
	pageNameTempObj = divObj.find("input[name='input-pageName']");
	formNameTempObj = divObj.find("input[name='input-formName']");
	objNameTempObj = divObj.find("input[name='input-objName']");
	//orderByObj = divObj.find("input[name='input-orderBy']");
	var pageName = pageNameTempObj.val();
	pageName=strUtil.doNull(pageName,thisMainObjName);
	var formName = formNameTempObj.val();
	loginWin = layer.open({
	    type: 2,
	    title:"IUS参数设置",
	    shadeClose: false,
	    shade: 0.6,
	    area: ['1100px', '600px'],
	    offset: '10px',
	    content: ctx+"/sendPage/plateform/admin/project/sysParamManager-list-sample?sysEname="+thisSysEname+"&objName="+thisMainObjName+"&pageName="+pageName+"&formName="+formName //iframe的url
//	    content: ctx+"/sendPage/plateform/admin/rule/params-list-sample?pageName="+pageName+"&formName="+formName //iframe的url
	}); 
}


//选中IUS后回调方法
function preIusCallBack(ob){
	layer.close(loginWin);
	var pageName = $(ob).attr("pagename");
	var formName = $(ob).attr("formname");
	var infoId = $(ob).attr("infoid");
	var modelTypes = $(ob).attr("modeltypes");
	rulesname = $(ob).attr("rulesname");
	pageNameTempObj.val(pageName);
	formNameTempObj.val(formName);
	var modelObjName=modelTypes;
	if(modelTypes.indexOf(",")>-1){
		modelObjName = modelTypes.split(",")[0];
	}
	//modelObjName = modelObjName.replace("s_","");
	
	if(modelObjName.indexOf("_")>-1){
		objNameTempObj.val(modelObjName.split("_")[1]);//objName
	}
	//var orderSortColum = "create_time";
	//var orderSort = "desc";
	//orderByObj.val(modelObjName+"."+orderSortColum+" "+orderSort);
}
//给页form-group追加可删除的工具条
function addGroupDragTools(id){
	var dragToolsHtml = "<div class='drag-tools text-left' style='display: none;'>";

    dragToolsHtml+="<div class='col-sm-8'><label class='label label-default fcur'>";
    dragToolsHtml+="<i class='fa fa-cog'></i>";
    dragToolsHtml+="</label></div>";

    dragToolsHtml+="<div class='col-sm-4'><label class='label label-default fcur'>";
    dragToolsHtml+="<i class='fa fa-trash-o'></i>";
    dragToolsHtml+="</label></div>";

    dragToolsHtml+="</div>";
	
	$("#"+id).find("label").attr("contenteditable",true);
	
	$("#"+id).find(".form-group").each(function(){
		$(this).after(dragToolsHtml);//同级追加工具条
		$(this).parent().find(".drag-tools").find("label").find(".fa-trash-o").click(function(){
			$(this).parent().parent().parent().parent().html("&nbsp;");//移除元素
		});
        $(this).parent().find(".drag-tools").find("label").find(".fa-cog").click(function(){
            thisFaCogObj = $(this);
            var titleName = $(this).parent().parent().parent().parent().prev().find("label").text();
            if(!strUtil.isNull(titleName))titleName=titleName.replace("：","");
            loginWin =  layer.open({
                type: 2,
                title:"控件校验选择器["+titleName+"]",
                shadeClose: false,
                shade: 0.6,
                area: ['600px', '400px'],
                content: page_admin+"/module/page-check-validator" //iframe的url
            });
        });
		$(this).parent().mouseenter(function () { 
			$(this).find(".drag-tools").show();
		}); 

		$(this).parent().mouseleave(function () {
			$(this).find(".drag-tools").hide();
		});
	});
}

//打开ueditor-iframe
function openDisplayForm(t){
	clearObject(thisCtrTable);
	loginWin = layer.open({
	    type: 2,
	    title:"设计表单",
	    shadeClose: false,
	    shade: 0.6,
	    area: ['90%', '90%'],
	    content: ctx+"/sendPage/plateform/admin/module/ueditor-iframe?type=1&flag="+new Date().getTime() //iframe的url
	}); 
}
//清空多余元素：p,td下的：多余属性，样式、内容等。
function clearObject(optObj){
	if(optObj){
		//alert(optObj.html());
		optObj.find("p").remove();
		optObj.find("tr").removeAttr("class");
		optObj.find("td").each(function(){
			$(this).removeAttr("style");
			$(this).find("label").removeAttr("contenteditable");//移除空h5的可编辑文本属性
			$(this).children().removeClass("has-feedback");//移除子元素定义has-feedback的class值
			if(strUtil.isNull($(this).attr("class")))$(this).removeAttr("class");//移除空class属性
			$(this).find("small").remove();//移除子元素small（是反显事所带的验证）
			$(this).find("i[class='form-control-feedback']").remove();//移除子元素i（是反显事所带的验证）
			$(this).find("select option:not(:first)").remove();
			$(this).find("[data-type-tag='radio']").html("[radio]");
			$(this).find("[data-type-tag='checkbox']").html("[checkbox]");
			$(this).find("[data-bv-field]").removeAttr("data-bv-field");
			
			$(this).find(".drag-tools").remove();
		});
	}
}
//切换ueditor-iframe和预览模式
function chartDisplayForm(n){
	var thisId = "tabs_checkboxed_colum_content";
	thisCtrTable = $("#"+thisId);
	if(n==1){
		addGroupDragTools(thisId);
		$("#btn-dis-1").addClass("btn-primary").removeClass("btn-default");
		$("#btn-dis-2").removeClass("btn-primary").addClass("btn-default");
		$("#tabs_checkboxed_colum_content").removeClass("hidden");
		$("#tabs_checkboxed_colum_content_display").addClass("hidden");
	}else{
		//alert(thisCtrTable);
		clearObject(thisCtrTable);
		$("#btn-dis-1").removeClass("btn-primary").addClass("btn-default");
		$("#btn-dis-2").addClass("btn-primary").removeClass("btn-default");
		$("#tabs_checkboxed_colum_content_display").removeClass("hidden");
		$("#tabs_checkboxed_colum_content").addClass("hidden");
		var u_url = ctx+"/sendPage/plateform/admin/module/ueditor-iframe?type=2&flag="+new Date().getTime();
		$("#iframe_display").attr("src",u_url);
	}
	
}
function preDisplayFormContent(obj,type){
	if(thisCtrTable){
		thisCtrTable.html(obj.content);
		$("#tabs_checkboxed_colum_content").html(obj.content);
	}
	if(type=="1"){
		layer.close(loginWin);
	}else{
		chartDisplayForm(1);
	}
}
function changeOrderSort(obj){
	var orderByObj = $("input[name='input-orderBy']");
	var orderVal = orderByObj.val();
	var thisVal = $(obj).val();
	if(thisVal=="desc"){
		orderVal=orderVal.replace("asc","desc");
	}else{
		orderVal=orderVal.replace("desc","asc");
	}
	orderByObj.val(orderVal);
}

//切换是否审核
function changeStartAuditTypeVal(obj,id){
	if($(obj).val()=="F"){
		$("#"+id).val("");
	}
}
//选择数据表对象
function showObjNameTable(){
	loginWin = layer.open({
	    type: 2,
	    title:"第一步、选择数据对象",
	    shadeClose: false,
	    shade: 0.6,
	    area: ['96%', '96%'],
	    offset: '10px',
	    content: ctx+"/sendPage/plateform/admin/sort/objName-table-pop?objNameStr="+strUtil.doNull(thisObjNameAll,"")+"&sysEname="+thisSysEname //iframe的url
	}); 
	$("input[name='input_primaryKey_objName']").val("");
	$("input[name='input_primaryKey_colum']").val("");
}
var tableObjNameMap = {};
function preObjTableCallBack(objMap){
	tableObjNameMap = objMap;
	layer.close(loginWin);
	var myData = {};
	var len  = Object.keys(tableObjNameMap).length;
	myData.total=len;
	var rowsColum=new Array();
	var i = 0;
	for(var key in tableObjNameMap){
		rowsColum[i]=tableObjNameMap[key];
		i++;
	}
	myData.rows=rowsColum;
	var pkeyHtml = baidu.template("modal_primary_key_set_content-template",eval(myData));
	$("#modal_primary_key_set_content").html(pkeyHtml);
	$("#modal_primary_key_set").modal("show");
}
//设置多表情况下，主表主键
function checkPkObjName(obj){
	var objNameAll = "";
	$("#modal_primary_key_set_content").find(".fa-check").each(function(){
		$(this).removeClass("fx3").removeClass("fx8");
		objNameAll +=$(this).attr("pkobj")+",";
	});
	if(!strUtil.isNull(objNameAll)){
		objNameAll=objNameAll.substring(0,objNameAll.length-1);
	}
	$(obj).removeClass("fx8").addClass("fx3");
	var pkobj = $(obj).attr("pkobj");
	var pkcolum = $(obj).attr("pkcolum");
	
	var contentHtmls= "\t\t\t\t\t\t\t\t\t\t<input name=\"mainObjName\" type=\"hidden\" value=\""+pkobj+"\">";
	contentHtmls+= "\n\t\t\t\t\t\t\t\t\t\t<input name=\"mainObjPrimaryKey\" type=\"hidden\" value=\""+pkcolum+"\">";
	contentHtmls+= "\n\t\t\t\t\t\t\t\t\t\t<input name=\"objNameAll\" type=\"hidden\" value=\""+objNameAll+"\">";
	//alert(contentHtmls);
	$("#hidden_common_final").html(contentHtmls);
	var hide_reslut=saveFileContent("hidden_common_final",contentHtmls);
	if(hide_reslut=="T"){
		saveRefresh();
	}
}

//从库里加载定义的对应类型附件信息
function showSysObjAttaListData(attaType){
	DictUtil.getCommonDictData("select","#select_sysObjAtta_objType","sysObjAtta.objType","doCode=dymicSql&modelTypes=s_sysAttaType","{value:'typeCode',text:'typeName'}",attaType);
	
	if(!strUtil.isNull(attaType)){
		var fileObjContent = $("#modal_file_group_content");
		var index_load = layer.msg("数据正在加载中。。。", {shade: false,offset: '220px'});
		var reqDataParm = {"modelTypes":"s_sysObjAtta","sysObjAtta.w_objType":attaType};
		$.get(common_list_url, reqDataParm,function(myData){
			layer.close(index_load);
			console.log(myData);
	    	fileObjContent.html(baidu.template("modal_file_group-template",eval(myData)));
	    	
	    	fileObjContent.find("tr").each(function(){
	    		var keyName = $(this).attr("name");
	    		if(checkedFileGroupMap[keyName]){
	    			$(this).addClass("bg-danger");
	    			var mapData = checkedFileGroupMap[keyName];
	    			$(this).find("input[name='fileObjName']").val(mapData.name);
	    			$(this).find("input:checkbox[name='checkbox_fileGroup']").prop("checked",true);
	    		}
	    	});
				
	   	},"json");
	}
	if(Object.keys(checkedFileGroupMap).length>0){
		showFileGroupMap();
	}
}
function changeSysObjAtta(obj){
	showSysObjAttaListData($(obj).val());
}

//保存附件文件选中
function checkFileGroup(obj){
	var objTr = $(obj).parent().parent();
	var fileObjName = objTr.find("input[name='fileObjName']");
	var key = objTr.attr("name");
	if($(obj).is(":checked")){
		if(strUtil.isNull(fileObjName.val())){
			layer.tips("输入存储附件地址的对象.属性！","#"+fileObjName.attr("id"),{tips:3});
			$(obj).prop("checked", false);
			return;
		}
		objTr.addClass("bg-danger");
		var name = fileObjName.val();
		//封装数据
		var title = $(obj).parent().parent().attr("name");//objTr.find("td").eq(1).text();
		var tempUrl = $(obj).attr("temp-url");
		checkedFileGroupMap[key] = eval({"name":name,"title":title,"type":"","tempUrl":tempUrl});
	}else{
		delete checkedFileGroupMap[key];//删除map元素
		objTr.removeClass("bg-danger");
	}
	
	showFileGroupMap();
}
//显示map中的内容预览
function showFileGroupMap(){
	//输出到模板
	var len  = Object.keys(checkedFileGroupMap).length;
	var myData = {};
	myData.total=len;
	var rowsColum=new Array();
	var i = 0;
	for(var key in checkedFileGroupMap){
		rowsColum[i]=checkedFileGroupMap[key];
		i++;
	}
	myData.rows=rowsColum;
	var checkFileGroupHtml = baidu.template("modal_file_group-preview-template",eval(myData));
	$("#modal_file_group_content_preview").html(checkFileGroupHtml);
}
//保存选择的附件文件项到页面双击区域中
function saveFileGroupCheckAll(){
	var len  = Object.keys(checkedFileGroupMap).length;
	if(len<1){
		layer.alert("请至少选择一项！");
		return;
	}
	var index_submit = layer.confirm("您确定要保存内容吗？", {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
	, function(){
		layer.close(index_submit);
		
	});
	var perviewFileGropHtml= $("#modal_file_group_content_preview").html();
	var fileDivId =  thisCtrObj.attr("id");
	var tempFileType =  $("#select_sysObjAtta_objType").val();
	var dataTempFormId = thisCtrObj.attr("addForm_content_3");
	var newContentText ="\n\t\t\t\t\t\t\t<div id=\""+fileDivId+"\" data-temp-code=\"true\" ";
	newContentText += "  data-temp-type=\"fileForm\" data-file-type=\""+tempFileType+"\">";
	newContentText += "\n\t\t\t\t\t\t\t\t"+perviewFileGropHtml;
	newContentText += "</div>";
	//alert(searchForm_newContentText);
	var result_flag = saveFileContent(fileDivId,newContentText);
	
}
//校验规则选择完成后回调
function preCheckValidator(dataJson){
    layer.close(loginWin);
    var regexp = dataJson.regexp;
    var tips = dataJson.tips;
    if(thisFaCogObj){
        var thisOptObjnameCotrs = thisFaCogObj.parent().parent().parent().parent().find("[data-temp-obj]");
        //alert(thisFaCogObj.parent().parent().parent().parent().html());
        thisOptObjnameCotrs.attr("placeholder",tips);
        thisOptObjnameCotrs.attr("data-bv-notempty","true");
        thisOptObjnameCotrs.attr("data-bv-notempty-message","此项不能为空！");
        thisOptObjnameCotrs.attr("data-bv-regexp","true");
        thisOptObjnameCotrs.attr("data-bv-regexp-regexp",regexp);
        thisOptObjnameCotrs.attr("data-bv-regexp-message",tips);
	}
}
</script>

<div class="modal fade" id="modal_colum_checkbox" tabindex="-2" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog" style="margin-top:10px; width:99%;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							×
						</button>
						<h4 class="modal-title">
							<font color="red">字段选择器[<span id="modal_colum_checkbox_title"></span>表]</font> 
						</h4>
					</div>
					<div class="modal-body box-body">
						<div class="col-lg-5" id="tabs_checkbox_1">
						 <div class="box box-info">
							<div class="box-header">
								<div class="col-lg-10" id="modal-btn-div">
								</div>
								<div class="col-lg-2 pull-right">
					                <button type="button" class="btn btn-box-tool pull-right" id="btn-box-tool-coll" onclick="chartDiv(this)" data-widget="collapse"><i class="fa fa-minus"></i></button>
				                 </div>
							</div>
					        <div class="box-body" style="border:0px red solid;">
								   <div id="div_table_colum_content" style="width:100%; height:500px;overflow-y:auto; overflow-x:hidden;">
									   <table class="table">
							                <thead class="bg-danger f12">
												<tr>
													<th width="10%">属性/名称/必填</th>
													<th width="30%">显示类型/选中使用</th>
													<th width="50%">预览效果</th>
												</tr>
											</thead>
											<tbody id="tabs_checkbox_content">
											</tbody>	
						               </table>
					               </div>
					        </div>
				        </div>
				       </div>
				        <div class="col-lg-7" id="tabs_checkbox_2">
					         <div class="box box-danger">
								<div class="box-header ">
				                 	<div class="col-lg-8">
				                 		<button id="btn-dis-dragsort-open" class="btn btn-success btn-xs" type="button" onclick="openDragSort()"><i class="fa fa-play-circle-o"></i> 开启拖拽排序</button>
						        		<button id="btn-dis-dragsort-close" class="btn btn-success btn-xs"  disabled="disabled" type="button" onclick="closeDragSort()"><i class="fa fa-stop-circle-o"></i> 关闭拖拽排序</button>
						        		<button id="btn-dis-1" class="btn btn-primary btn-xs" type="button" onclick="chartDisplayForm(1)"><i class="fa fa-font"></i> 填充内容</button>
						        		<button id="btn-dis-2" class="btn btn-default btn-xs" type="button" onclick="chartDisplayForm(2)"><i class="fa fa-table"></i> 表格编辑</button>
									</div>
				                 	<div class="col-sm-4 text-right">
				                 		<button type="button" class="btn btn-danger btn-sm pull-right" onclick="checkAllOkAndSave();"> <i class="fa fa-check-square-o"></i> 保存设计完成 </button>  
				                 	</div>
				                 </div>
						        <div class="box-body" style="border:0px green solid;">
									<div id="tabs_checkboxed_colum_content">
										
							        </div>
							        <div class="hidden" id="tabs_checkboxed_colum_content_display" style="border:0px red solid;">
							        	<iframe id="iframe_display" width="100%" height="500px" scrolling="yes" frameborder="0"></iframe>
							        </div>
						        </div>
					        </div>
				        </div>
					</div>
				</div>
	</div>
</div>	
		
<div class="modal fade" id="modal_event_target_set" tabindex="-2" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog" style="top:10%; width:70%;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							×
						</button>
						<h4 class="modal-title">
							<font color="red">相关接口参数设置</font> 
						</h4>
					</div>
					<div class="modal-body box-body" id="div_event_target_modal_content">
							<div class="auditForm form-group col-lg-12 hidden">
						   		<label class="col-lg-4 control-label">表单提交是否启动审核：</label>
						   		<div class="col-lg-8">
									<div class="input-group">
										<select name="startAudit" onchange="changeStartAuditTypeVal(this,'input-auditType-id')" class="form-control">
											<option value="F" selected="selected">否</option>
											<option value="T">是</option>
										</select>
										<div class="input-group-addon">审核类型[auditType]：</div>
										<input class="form-control" id="input-auditType-id" name="input-auditType" maxlength="50" placeholder="对应审核规则中类型！" />
									  </div>
						   		</div>
						   </div>
						   
						   		<div class="form-group col-lg-12">
								   		<label class="col-lg-4 control-label">当前操作区域元素ID：</label>
								   		<div class="col-lg-8">
											<input class="form-control" readonly="readonly" name="input-formId" maxlength="50"/>
								   		</div>
								   </div>
				        		<div class="iusForm form-group col-lg-12">
								   		<label class="col-lg-4 control-label">页面名称[pageName]：</label>
								   		<div class="col-lg-8">
								   			<div class="input-group">
												<input class="form-control" readonly="readonly" name="input-pageName" maxlength="50"/>
												<div class="input-group-addon red">
													<button type="button" class="btn btn-primary btn-xs" onclick="toOpenIus('div_event_target_modal_content')"> <i class="fa fa-cog"></i> 选择设置</button>
												</div>
											</div>
								   		</div>
								   </div>
								   <div class="iusForm form-group col-lg-12">
								   		<label class="col-lg-4 control-label">表单名称[formName]：</label>
								   		<div class="col-lg-8">
											<input class="form-control" readonly="readonly" id="input-formName-id" name="input-formName" maxlength="50"/>
								   		</div>
								   </div>
								   <div class="locationForm form-group col-lg-12 hidden">
								   		<label class="col-lg-4 control-label">操作跳转地址[location]：</label>
								   		<div class="col-lg-8">
											<input class="form-control" id="input-location-id" name="input-location" maxlength="50" placeholder="格式如：/sendPage/imp/admin/pubinfo/test-view"/>
											<span class="f12 fx12"><i class="fa fa-info-circle"></i> 当此操作点击后需要跳转其他页面时，此项必填，否则为空！</span>
								   		</div>
								   </div>
								  <!-- 
								   <div class="form-group col-lg-12">
								   		<label class="col-lg-4 control-label">默认排序[orderBy]：</label>
								   		<div class="col-lg-6">
								   			<input class="form-control" readonly="readonly" name="input-orderBy" maxlength="50"/>
								   		</div>
								   		<div class="col-lg-2">
								   			<select class="form-control" name="select-orderSort" onchange="changeOrderSort(this)">
								   				<option selected="selected" value="desc">倒序</option>
								   				<option value="asc">正序</option>
								   			</select>
								   		</div>
								   </div>
								    -->
								   <div class="form-group col-lg-12 text-center">
								   		<button type="button" class="btn btn-danger" onclick="saveEventTarget('div_event_target_modal_content')"> <i class="fa fa-cog"></i> 保存设置</button>
								   </div>
					</div>
				</div>
			</div>	
</div>
<div class="modal fade" id="modal_primary_key_set" tabindex="-2" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog" style="width:60%;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							×
						</button>
						<h4 class="modal-title">
							<font color="red">第二步、勾选主表</font> 
						</h4>
					</div>
					<div class="modal-body box-body">
				        <div class="form-group col-lg-12" id="modal_primary_key_set_content">
						</div>
					</div>
				</div>
			</div>	
</div>

<div class="modal fade" id="modal_contextmenu_set" tabindex="-2" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog" style="width:50%;top:5%;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							×
						</button>
						<h4 class="modal-title">更改跨列数</h4>
					</div>
					<div class="modal-body box-body">
				        <div class="form-group col-lg-12">
					        	<label class="col-lg-3 text-right red" id="contextmenu_filed_title"></label>
								<div class="form-group col-lg-6">
						        	<select class="form-control" id="contextmenu_select" onchange="changeColumSiginOne(this)">
										<option value="12">col-lg-12</option>
										<option value="10">col-lg-10</option>
										<option value="8">col-lg-8</option>
										<option value="6">col-lg-6</option>
										<option value="4">col-lg-4</option>
									</select>
								</div>
						</div>
					</div>
				</div>
			</div>	
</div>

<div class="modal fade" id="modal_file_group" tabindex="-2" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog" style="margin-top:10px; width:90%;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							×
						</button>
						<h4 class="modal-title">
							<font color="red">附件定义选择器 [数据来自：<span id="modal_colum_checkbox_title">sysObjAtta</span>表]</font> 
						</h4>
					</div>
					<div class="modal-body box-body">
						 <div class="box box-info">
						 	<div class="box-header ">
			                 	<div class="col-sm-6">
			                 		附件类型：<select id="select_sysObjAtta_objType" onchange="changeSysObjAtta(this)"
			                 		class="form-control form-control-content">
									</select>
			                 	</div>
			                 	<div class="col-sm-6">
			                 		<button type="button" class="btn btn-danger pull-right" onclick="saveFileGroupCheckAll();"> <i class="fa fa-check"></i> 选择完成 </button>
			                 	</div>
			                 </div>
					        <div class="box-body">
					        		<div class="col-sm-6">
								   <table class="table table-bordered table-hover">
						                <thead class="bg-danger">
											<tr>
												<th width="5%">+</th>
												<th width="55%">附件名称</th>
												<th width="35%">配置存储的 对象.属性</th>
												<th width="10%" class="text-center"><i class="fa fa-check"></i></th>
											</tr>
										</thead>
										<tbody id="modal_file_group_content">
										</tbody>	
					               </table>
					               </div>
					               <div class="col-sm-6" id="modal_file_group_content_preview">
					               		
					               </div>
					        </div>
				        </div>
				        </div>
					</div>
				</div>
				<!-- /.modal-content -->
</div>
	
	
<script type="text/template" id="tabs_checkbox_content-template">
	<? for ( var i = 0; i < rows.length; i++) {?>
	<tr name="<?=objName+"."+rows[i].metadata.dataAttr?>" metadata-id="<?=rows[i].metadata.metadataId?>" metadata-restrict="<?=rows[i].metadata.dataRestrict?>">
        <td>
				<div class="input-group">
					<label class="f12"><?=rows[i].metadata.dataFullName?></label>
					<div class="input-group-addon f12">
						<input type="checkbox" name="checkbox_dataValid" <?if(rows[i].metadata.dataAttr=='fsId'){?>disabled<?}?>/>
					</div>
			 	</div>
				<div class="f12"><?=objName+"."+rows[i].metadata.dataAttr?></div>
		</td>
		<td>
			<div class="input-group">
				<select <?if(tempType=='table'||rows[i].metadata.dataAttr=='fsId'||rows[i].metadata.dataRestrict=='1'){?>disabled<?}?> onchange="setColumParam(this,'<?=rows[i].metadata.metadataId?>')" name="select_columType" class="form-control f12" style="width:100px;">
					<option value="input" <?if(tempType=='addForm' || tempType=='editForm' || tempType=='viewForm'){?>selected="selected"<?}?>>input-输入框</option>
					<option value="select">select-下拉框</option>
					<?if(tempType=='searchForm' || tempType=='addForm' || tempType=='editForm'){?>
					<option value="date">date-日期框</option>
					<option value="hidden" <?if(rows[i].metadata.dataAttr=='fsId'||rows[i].metadata.dataRestrict=='1'){?>selected="selected"<?}?>>hidden-隐藏域</option>
					<?}?>
					<?if(tempType=='addForm' || tempType=='editForm'){?>
					<option value="radio">radio-单选框</option>
				    <option value="uploadImg">uploadImg-上传图片</option>
					<option value="uploadFile">uploadFile-上传文件</option>
					<option value="textarea">textarea-文本域</option>
					<option value="checkbox">checkbox-复选框</option>
					<option value="rele">rele-三级联动</option>
					<option value="password">password-密码框</option>
					<option value="selectMultiple">multiple-下拉多选</option>
					<?}?>
					<?if(tempType=='viewForm'){?>
				    <option value="uploadImg">uploadImg-上传</option>
					<option value="uploadFile">uploadFile-上传文件</option>
					<option value="checkbox">checkbox-复选框</option>
					<option value="rele">rele-三级联动</option>
					<?}?>
					<?if(tempType=='table'){?>
					<option value="th" selected="selected">table表头th</option>
					<?}?>
				</select>
				<div class="input-group-addon f12">
					<input type="checkbox" name="checkbox_objname" onclick="checkColumAttr(this)" colum="<?=rows[i].metadata.dataAttr?>" colum-title="<?=rows[i].metadata.dataFullName?>"/>
				</div>
			 </div>
		</td>
		<td>
			&nbsp;
		</td>
		</tr>

		<tr id="div_req_<?=rows[i].metadata.metadataId?>" style="display:none;">
			<td colspan="3">
					<div class="form-group" id="div_select_dict_<?=rows[i].metadata.metadataId?>" style="display:none;">
					  <div class="input-group">
						<div class="input-group-addon red f12">元素来源</div>
						<select id="select_req_type_<?=rows[i].metadata.metadataId?>" name="select_req_type" onchange="changeReqTypeVal(this,'<?=rows[i].metadata.metadataId?>')" class="form-control f12">
							<option value="dictItemList" selected="selected">来自数据字典</option>
							<option value="dymicSql">自定义IUS动态表</option>
						</select>
						<div class="input-group-addon red f12">标识</div>
						<input id="input_req_typecode_<?=rows[i].metadata.metadataId?>" name="input_req_typecode" class="form-control f12" maxlength="30" />
					  </div>
						<div class="input-group" id="div_iusparams_<?=rows[i].metadata.metadataId?>" style="display:none;">
							<div class="input-group-addon red f12">接口参数</div>
							<input id="input_dymic_page_name_<?=rows[i].metadata.metadataId?>" readonly="readonly" name="input-pageName" class="form-control f12" maxlength="30" />
							<div class="input-group-addon red f12">|</div>
							<input id="input_dymic_form_name_<?=rows[i].metadata.metadataId?>" readonly="readonly" name="input-formName" class="form-control f12" maxlength="30" value="dictForm"/>
							<input type="hidden" id="input_dymic_obj_name_<?=rows[i].metadata.metadataId?>" readonly="readonly" name="input-objName" class="form-control f12" maxlength="30" value=""/>
							<div class="input-group-addon red">
								<button type="button" class="btn btn-primary btn-xs" onclick="toOpenIus('div_iusparams_<?=rows[i].metadata.metadataId?>')"> 选择</button>
							</div>
					  	</div>

					</div>
					<div class="form-group" id="div_resColmun_<?=rows[i].metadata.metadataId?>" style="display:none;">
						<div class="input-group">
							<div class="input-group-addon red f12">返回参数</div>
							<input disabled="disabled" id="input_resColmun_<?=rows[i].metadata.metadataId?>" name="input_resColmun" class="form-control f12" maxlength="100"/>
						</div>
						<div class="f12 fx12"><i class="fa fa-info-circle"></i> 格式如{value:'cateNo',text:'cateName',other:'sysName'} (other可选)</div>
						<div class="input-group hidden">
							<div class="input-group-addon red f12">其他条件</div>
							<input id="input_resCondition_<?=rows[i].metadata.metadataId?>" name="input_resCondition" class="form-control f12" maxlength="100"/>
						</div>
					</div>
				   <div class="form-group" id="div_rele_select_<?=rows[i].metadata.metadataId?>" style="display:none;">
						<div class="input-group">
							<div class="input-group-addon red f12">一级字段</div>
							<input id="input_rele_first_<?=rows[i].metadata.metadataId?>" value="<?=rows[i].metadata.dataAttr?>" name="input_rele_first" class="form-control f12" maxlength="20"/>
							<div class="input-group-addon red f12">二级字段</div>
							<input id="input_rele_second_<?=rows[i].metadata.metadataId?>" name="input_rele_second" class="form-control f12" maxlength="20"/>
							<div class="input-group-addon red f12">三级字段</div>
							<input id="input_rele_third_<?=rows[i].metadata.metadataId?>" name="input_rele_third" class="form-control f12" maxlength="20"/>
						</div>
					</div>
					<div class="form-group" id="div_hidden_field_def_<?=rows[i].metadata.metadataId?>" style="display:none;">
						<div class="input-group">
							<div class="input-group-addon red f12">填写隐藏域默认值</div>
							<input id="input_hidden_field_def_<?=rows[i].metadata.metadataId?>" name="input_hidden_field_def" class="form-control f12" maxlength="30"/>
						</div>
					</div>
			</td>
		</tr>
   <?}?>
</script>
<script type="text/template" id="searchForm-preview-template">
	<? for ( var i = 0; i < rows.length; i++) {?>
		<div class="form-group col-lg-<?=rows[i].dataColVal?> drag-box" data-col-val="<?=rows[i].dataColVal?>" title="拖拽排序" style="border:1px dashed #999;padding:5px 0 5px 0;">
			<label><?=rows[i].title?>：</label>
			<?if(rows[i].type=='input'){?>
				<input name="<?=rows[i].objName?>.wl_<?=rows[i].colum?>" class="form-control form-control-content clean" maxlength="30"  data-temp-obj="<?=rows[i].name?>" data-temp-title="<?=rows[i].title?>" type="text"/>
			<?}else if(rows[i].type=='select'){?>
				<select id="<?=formId?>_<?=rows[i].objName?>_<?=rows[i].colum?>" name="<?=rows[i].objName?>.<?=rows[i].colum?>" class="form-control form-control-content clean" data-temp-obj="<?=rows[i].name?>" data-temp-title="<?=rows[i].title?>"  data-dict-code="<?=rows[i].dataDictCode?>" data-dict-cate="<?=rows[i].dataDictCate?>" data-colmun="<?=strUtil.doNull(rows[i].dataColmun,'')?>" data-condition="<?=strUtil.doNull(rows[i].dataCondition,'')?>" data-type-tag="<?=rows[i].type?>">
					<option value="">--请选择--</option>
				</select>
			<?}else if(rows[i].type=='date'){?>
				<div class="input-append form-control-content">
					<input name="<?=rows[i].objName?>.wl_<?=rows[i].colum?>" maxlength="30" data-temp-obj="<?=rows[i].name?>" data-temp-title="<?=rows[i].title?>" class="form-control form-control-content clean datepicker" readonly="readonly" type="text" data-type-tag="<?=rows[i].type?>"/>
					<span class="add-on"> <i class="fa fa-calendar"></i></span>
				</div>
 			<?}else if(rows[i].type=='hidden'){?>
				<input type="hidden" name="<?=rows[i].objName?>.wl_<?=rows[i].colum?>" data-temp-obj="<?=rows[i].name?>" data-temp-title="<?=rows[i].title?>" data-type-tag="<?=rows[i].type?>" value="<?=rows[i].dataDefVal?>"/>
				隐藏域 <?=rows[i].dataDefVal?>
			<?}?>
			</div>
		</div>
   <?}?>  		
</script>
<script type="text/template" id="form-preview-template">
	<? for ( var i = 0; i < rows.length; i++) {?>
<?if(i==0){?><tr><?}?>
<?if(i>0 && i%3==0){?></tr><tr><?}?>
<td>
	<?if(rows[i].type=='rele'){?>
		<div class="form-group col-lg-<?=rows[i].dataColVal?> drag-box" data-col-val="<?=rows[i].dataColVal?>" 
			id="<?=strUtil.doNull(formId,'')?>_rele<?=(i+1)?>_<?=rows[i].objName?>_<?=rows[i].colum?>" data-type-tag="<?=rows[i].type?>" 
			data-temp-obj="<?=rows[i].name?>" data-temp-title="<?=rows[i].title?>" data-rele-code="<?=rows[i].dataDictCate?>"  
			rele-first=".prov" rele-second=".city" rele-third=".dist" 
			rele-first-def="" rele-second-def="" rele-third-def=""<?if(rows[i].dataValid=='true'){?> data-bv-notempty="true" data-bv-notempty-message="不能为空" <?}?>  
			title="拖拽排序" style="border:1px dashed #999;padding:5px 0 5px 0;">
				<label><?=rows[i].title?>：</label>
				<div class="form-control-content">
					<select name="<?=rows[i].dataReleVal[0]?>" class="prov form-control clean" style="width:20%">
						<option value="">--请选择--</option>
					</select>&nbsp;&nbsp;
					<select name="<?=rows[i].dataReleVal[1]?>" class="city form-control clean" style="width:20%">
						<option value="">--请选择--</option>
					</select>&nbsp;&nbsp;
					<select name="<?=rows[i].dataReleVal[2]?>" class="dist form-control clean" style="width:20%">
						<option value="">--请选择--</option>
					</select>
				</div>
		</div>
	<?}else{?>
		<div class="form-group col-lg-<?=rows[i].dataColVal?> drag-box" data-col-val="<?=rows[i].dataColVal?>" title="拖拽排序" style="border:1px dashed #999;padding:5px 0 5px 0;">
			<label><?=rows[i].title?>：</label>
			<?if(rows[i].type=='input'){?>
				<input name="<?=rows[i].name?>" class="form-control form-control-content clean" maxlength="30"  data-temp-obj="<?=rows[i].name?>" data-temp-title="<?=rows[i].title?>" <?if(rows[i].dataValid=='true'){?> placeholder="必填项" data-bv-notempty="true" data-bv-notempty-message="不能为空" <?}?>/>
			<?}else if(rows[i].type=='password'){?>
				<input type="password" name="<?=rows[i].name?>" class="form-control form-control-content clean" maxlength="30"  data-temp-obj="<?=rows[i].name?>" data-temp-title="<?=rows[i].title?>" data-type-tag="<?=rows[i].type?>" <?if(rows[i].dataValid=='true'){?> placeholder="必填项" data-bv-notempty="true" data-bv-notempty-message="不能为空" <?}?>/>
			<?}else if(rows[i].type=='select'){?>
				<select id="<?=formId?>_<?=rows[i].objName?>_<?=rows[i].colum?>" name="<?=rows[i].objName?>.<?=rows[i].colum?>" class="form-control form-control-content clean" data-temp-obj="<?=rows[i].name?>" data-temp-title="<?=rows[i].title?>"  data-dict-code="<?=rows[i].dataDictCode?>" data-dict-cate="<?=rows[i].dataDictCate?>" data-colmun="<?=strUtil.doNull(rows[i].dataColmun,'')?>" data-condition="<?=strUtil.doNull(rows[i].dataCondition,'')?>" data-type-tag="<?=rows[i].type?>" <?if(rows[i].dataValid=='true'){?> placeholder="必填项" data-bv-notempty="true" data-bv-notempty-message="不能为空" <?}?> data-def="">
					<option value="">--请选择--</option>
				</select>
			<?}else if(rows[i].type=='radio' || rows[i].type=='checkbox'){?>
				<div class="form-control-content" id="<?=formId?>_<?=rows[i].objName?>_<?=rows[i].colum?>" name="<?=rows[i].objName?>.<?=rows[i].colum?>" data-temp-obj="<?=rows[i].name?>" data-temp-title="<?=rows[i].title?>" data-dict-code="<?=rows[i].dataDictCode?>" data-dict-cate="<?=rows[i].dataDictCate?>" data-colmun="<?=strUtil.doNull(rows[i].dataColmun,'')?>" data-condition="<?=strUtil.doNull(rows[i].dataCondition,'')?>" data-type-tag="<?=rows[i].type?>" data-def="">
				</div>
 			<?}else if(rows[i].type=='date'){?>
				<div class="input-append form-control-content">
					<input name="<?=rows[i].objName?>.<?=rows[i].colum?>" data-temp-obj="<?=rows[i].name?>" data-temp-title="<?=rows[i].title?>" data-type-tag="<?=rows[i].type?>" maxlength="30" class="form-control form-control-content clean datepicker" readonly="readonly" type="text"/>
					<span class="add-on"> <i class="fa fa-calendar"></i></span>
				</div>
 			<?}else if(rows[i].type=='uploadImg'){?>
				<div file-box="true" class="form-control-content" name="<?=rows[i].objName?>.<?=rows[i].colum?>" data-temp-obj="<?=rows[i].name?>" data-temp-title="<?=rows[i].title?>" data-type-tag="<?=rows[i].type?>">
					 <img file-img="true" src="/images/def.jpg" style="width:120px;height:80px;"/>
					 <label file-btn="true" onclick="addUploadFileNew(this);" for="uploadFileInputNew" class="btn btn-warning">选择图片</label>
					 <input file-input="true" name="<?=rows[i].objName?>.<?=rows[i].colum?>" type="hidden" class="clean"/>
					 <a file-a="true" href="#" style="display:none;" target="_bank"></a>
					 <label file-msg="true" style="color:red;display:none;"></label>
				</div>
			<?}else if(rows[i].type=='uploadFile'){?>
				<div file-box="true" class="form-control-content" name="<?=rows[i].objName?>.<?=rows[i].colum?>" data-temp-obj="<?=rows[i].name?>" data-temp-title="<?=rows[i].title?>" data-type-tag="<?=rows[i].type?>">
					 <label file-btn="true" onclick="addUploadFileNew(this);" for="uploadFileInputNew" class="btn btn-primary">选择文件</label>
					 <input file-input="true" name="<?=rows[i].objName?>.<?=rows[i].colum?>" type="hidden" class="clean"/>
					 <a file-a="true" href="#" target="_bank"></a>
					 <label file-msg="true" class="red"></label>
				</div>
 			<?}else if(rows[i].type=='hidden'){?>
				<input type="hidden" name="<?=rows[i].name?>" data-temp-obj="<?=rows[i].name?>" data-temp-title="<?=rows[i].title?>" data-type-tag="<?=rows[i].type?>" <?if(rows[i].colum=='fsId'){?>value="fsId"<?}else{?>value="<?=rows[i].dataDefVal?>"<?}?>/>
				隐藏域 <?=rows[i].dataDefVal?>
			<?}else if(rows[i].type=='textarea'){?>
				<textarea class="form-control form-control-content clean" rows="2" maxlength="1000" name="<?=rows[i].objName?>.<?=rows[i].colum?>" data-temp-obj="<?=rows[i].name?>" data-temp-title="<?=rows[i].title?>"></textarea> 
			<?}?>
			</div>
		</div>
	<?}?>
</td>
   <?}?>  		
</script>
<script type="text/template" id="form-group-item-template">
	<? for ( var i = 0; i < rows.length; i++) {?>
  <?if('table'==tempType){?>
		<div class="form-group col-lg-4 text-center drag-box" contenteditable="true" data-temp-obj="<?=rows[i].name?>" style="border:1px dashed #999;padding:5px 0 5px 0;margin:5px 0 5px;">
			<?=rows[i].title?>
		</div>	
  <?}else{?>
   <div class="drag-box" style="border:1px dashed #999;padding:2px;z-index:100;">
	<?if(rows[i].type=='rele'){?>
		<div class="form-group" style="width:100%"  
			id="<?=strUtil.doNull(formId,'')?>_rele<?=(i+1)?>_<?=rows[i].objName?>_<?=rows[i].colum?>" data-type-tag="<?=rows[i].type?>" 
			data-temp-obj="<?=rows[i].name?>" data-temp-title="<?=rows[i].title?>" data-rele-code="<?=rows[i].dataDictCate?>"  
			rele-first=".prov" rele-second=".city" rele-third=".dist" 
			rele-first-def="" rele-second-def="" rele-third-def=""<?if(rows[i].dataValid=='true'){?> data-bv-notempty="true" data-bv-notempty-message="不能为空" <?}?>  >
				<div class="form-control-content">
					<select name="<?=rows[i].dataReleVal[0]?>" class="prov form-control clean" style="width:20%">
						<option value="">--请选择--</option>
					</select>&nbsp;&nbsp;
					<select name="<?=rows[i].dataReleVal[1]?>" class="city form-control clean" style="width:20%">
						<option value="">--请选择--</option>
					</select>&nbsp;&nbsp;
					<select name="<?=rows[i].dataReleVal[2]?>" class="dist form-control clean" style="width:20%">
						<option value="">--请选择--</option>
					</select>
				</div>
		</div>
		<div class="drag-tools text-left">
			<label class="label label-default fcur"><i class="fa fa-arrows"></i> 可拖动</label>
		</div>
	<?}else{?>
		
		<div class="form-group">
			<?var commObjName = rows[i].name?>
			<?if(tempType=='searchForm'){commObjName = rows[i].objName+'.wl_'+rows[i].colum }?>
			
			<?if(rows[i].type=='input'){?>
				<input name="<?=commObjName?>" class="form-control clean" maxlength="30"  data-temp-obj="<?=rows[i].name?>" <?if(rows[i].dataValid=='true'){?> placeholder="必填项" data-bv-notempty="true" data-bv-notempty-message="不能为空" <?}?>/>
			<?}else if(rows[i].type=='password'){?>
				<input type="password" name="<?=rows[i].name?>" class="form-control clean" maxlength="30"  data-temp-obj="<?=rows[i].name?>" data-type-tag="<?=rows[i].type?>" <?if(rows[i].dataValid=='true'){?> placeholder="必填项" data-bv-notempty="true" data-bv-notempty-message="不能为空" <?}?>/>
			<?}else if(rows[i].type=='select'){?>
				<select id="<?=formId?>_<?=rows[i].objName?>_<?=rows[i].colum?>" name="<?=commObjName?>" class="form-control  clean" data-temp-obj="<?=rows[i].name?>"  data-dict-code="<?=rows[i].dataDictCode?>" data-dict-cate="<?=rows[i].dataDictCate?>" 
					<?if(rows[i].dataDictCode!='dictItemList'){?> data-colmun="<?=strUtil.doNull(rows[i].dataColmun,'')?>" data-obj-name="<?=strUtil.doNull(rows[i].dymicDataObjName,'')?>" data-page-name="<?=strUtil.doNull(rows[i].dymicPageName,'')?>" data-form-name="<?=strUtil.doNull(rows[i].dymicFormName,'')?>" data-condition="<?=strUtil.doNull(rows[i].dataCondition,'')?>" <?}?> 
					<?if(rows[i].type=='selectMultiple'){?> multiple="multiple" data-multiple-result-id="<?=formId?>_<?=rows[i].objName?>_<?=rows[i].colum?>_multiple_result" data-multiple-result-hidden-name="<?=commObjName?>" <?}?> 
					 data-type-tag="<?=rows[i].type?>" <?if(rows[i].dataValid=='true'){?> placeholder="必填项" data-bv-notempty="true" data-bv-notempty-message="不能为空" <?}?> data-def="">
					<option value="">--请选择--</option>
				</select>
			<?}else if(rows[i].type=='selectMultiple'){?>
				<select id="<?=formId?>_<?=rows[i].objName?>_<?=rows[i].colum?>" name="<?=commObjName?>_temp" class="form-control  clean" data-temp-obj="<?=rows[i].name?>"  data-dict-code="<?=rows[i].dataDictCode?>" data-dict-cate="<?=rows[i].dataDictCate?>" 
					<?if(rows[i].dataDictCode!='dictItemList'){?> data-colmun="<?=strUtil.doNull(rows[i].dataColmun,'')?>" data-obj-name="<?=strUtil.doNull(rows[i].dymicDataObjName,'')?>" data-page-name="<?=strUtil.doNull(rows[i].dymicPageName,'')?>" data-form-name="<?=strUtil.doNull(rows[i].dymicFormName,'')?>" data-condition="<?=strUtil.doNull(rows[i].dataCondition,'')?>" <?}?> 
					<?if(rows[i].type=='selectMultiple'){?> multiple="multiple" data-multiple-result-id="<?=formId?>_<?=rows[i].objName?>_<?=rows[i].colum?>_multiple_result" data-multiple-result-hidden-name="<?=commObjName?>" <?}?> 
					 data-type-tag="<?=rows[i].type?>" <?if(rows[i].dataValid=='true'){?> placeholder="必填项" data-bv-notempty="true" data-bv-notempty-message="不能为空" <?}?> data-def="">
					<option value="">--请选择--</option>
				</select>
			<?}else if(rows[i].type=='radio' || rows[i].type=='checkbox'){?>
				<div class="form-control-static" id="<?=formId?>_<?=rows[i].objName?>_<?=rows[i].colum?>" name="<?=rows[i].objName?>.<?=rows[i].colum?>" data-temp-obj="<?=rows[i].name?>" data-dict-code="<?=rows[i].dataDictCode?>" data-dict-cate="<?=rows[i].dataDictCate?>" data-colmun="<?=strUtil.doNull(rows[i].dataColmun,'')?>" data-condition="<?=strUtil.doNull(rows[i].dataCondition,'')?>" data-type-tag="<?=rows[i].type?>" data-def="">
					[<?=rows[i].type?>]
				</div>
 			<?}else if(rows[i].type=='date'){?>
				<div class="input-append ">
					<input name="<?=commObjName?>" data-temp-obj="<?=rows[i].name?>" data-type-tag="<?=rows[i].type?>" maxlength="30" class="form-control clean datepicker" readonly="readonly" type="text" style="width:88%" <?if(rows[i].dataValid=='true'){?> placeholder="必填项" data-bv-notempty="true" data-bv-notempty-message="不能为空" <?}?>/>
					<span class="add-on"> <i class="fa fa-calendar"></i></span>
				</div>
 			<?}else if(rows[i].type=='uploadImg'){?>
				<div file-box="true" name="<?=rows[i].objName?>.<?=rows[i].colum?>" data-temp-obj="<?=rows[i].name?>" data-type-tag="<?=rows[i].type?>">
					 <img file-img="true" src="/images/def.jpg" style="width:120px;height:80px;"/>
					 <label file-btn="true" onclick="addUploadFileNew(this);" for="uploadFileInputNew" class="btn btn-warning">选择图片</label>
					 <input file-input="true" name="<?=rows[i].objName?>.<?=rows[i].colum?>" type="hidden" class="clean"/>
					 <a file-a="true" href="#" style="display:none;" target="_bank"></a>
					 <label file-msg="true" style="color:red;display:none;"></label>
				</div>
			<?}else if(rows[i].type=='uploadFile'){?>
				<div file-box="true" name="<?=rows[i].objName?>.<?=rows[i].colum?>" data-temp-obj="<?=rows[i].name?>" data-type-tag="<?=rows[i].type?>">
					 <label file-btn="true" onclick="addUploadFileNew(this);" for="uploadFileInputNew" class="btn btn-primary">选择文件</label>
					 <input file-input="true" name="<?=rows[i].objName?>.<?=rows[i].colum?>" type="hidden" class="clean"/>
					 <a file-a="true" href="#" target="_bank"></a>
					 <label file-msg="true" class="red"></label>
				</div>
 			<?}else if(rows[i].type=='hidden'){?>
				<input type="hidden" name="<?=commObjName?>" data-temp-obj="<?=rows[i].name?>" data-type-tag="<?=rows[i].type?>" <?if(rows[i].colum=='fsId'){?>value="fsId"<?}else{?>value="<?=rows[i].dataDefVal?>"<?}?>/>
				隐藏域 <?=rows[i].dataDefVal?>
			<?}else if(rows[i].type=='textarea'){?>
				<textarea class="form-control clean" rows="2" maxlength="1000" name="<?=rows[i].objName?>.<?=rows[i].colum?>" data-temp-obj="<?=rows[i].name?>" data-temp-title="<?=rows[i].title?>"></textarea> 
			<?}?>
			</div>
		
		<div class="drag-tools text-left">
			<label class="label label-default fcur"><i class="fa fa-arrows"></i> 可拖动</label>
		</div>
</div>
	<?}?>
</div>
<?}?>
   <?}?>  		
</script>
<script type="text/template" id="table-preview-template">
	<? for ( var i = 0; i < rows.length; i++) {?>
		<div class="form-group col-lg-4 text-center drag-box" contenteditable="true" data-temp-obj="<?=rows[i].name?>" style="border:1px dashed #999;padding:5px 0 5px 0;margin:5px 0 5px;">
			<?=rows[i].title?>
		</div>		
   <?}?>
</script>
<script type="text/template" id="modal_primary_key_set_content-template">
	<? for ( var i = 0; i < rows.length; i++) {?>
	<div class="col-lg-6"> 
		<div class="box box-primary">
			<div class="box-body f14">
				<p>说明：<?=rows[i].tableTextName?> &nbsp; （<?=rows[i].tableName?>）</p>
				<p>对象：<?=rows[i].tableObjName?></p>
 				<p>主键：<?=rows[i].tablePrimaryKeys?></p>
				<p class="pull-right"><i class="fa fa-check f30 fcur" pkobj="<?=rows[i].tableObjName?>" pkcolum="<?=rows[i].tablePrimaryKeys?>" onclick="checkPkObjName(this)"></i></p>
			</div>
		</div>
 	</div>
   <?}?>
</script>
<script type="text/template" id="modal_file_group-template">
	<? for ( var i = 0; i < rows.length; i++) {?>
		<tr id="file_group_<?=rows[i].infoId?>" name="<?=strUtil.doNull(rows[i].attaName,'')?>">
			<td><?=(i+1)?></td>
           	<td><?if(!strUtil.isNull(rows[i].tempUrl)){?><i class='fa fa-file-word-o fx2'></i> <?}?><?=strUtil.doNull(rows[i].attaName,'')?></td>
			<td>
			<input id="file_obj_name_<?=rows[i].infoId?>" name="fileObjName" class="form-control" maxlength="30" placeholder="格式：对象.属性"/>
			</td>
			<td class="text-center">
				<input type="checkbox" name="checkbox_fileGroup" title="<?=strUtil.doNull(rows[i].attaName,'')?>" temp-url="<?=strUtil.doNull(rows[i].tempUrl,'')?>" onclick="checkFileGroup(this)" />
			</td>
		</tr>
   <?}?>
</script>

<script type="text/template" id="modal_file_group-preview-template">
<table class="table table-bordered">
	<thead>
		<tr>
		<th width="10%">序号</th>
		<th width="60%">文件名称</th>
		<th width="30%">操作</th>
		</tr>
	</thead>
	<tbody>
	<? for ( var i = 0; i < rows.length; i++) {?>
		<tr>
		<td><?=(i+1)?></td>
		<td><?=rows[i].title?> <?if(!strUtil.isNull(rows[i].tempUrl)){?><a class="red" href="<?=rows[i].tempUrl?>">[下载]</a><?}?></td>
		<td>
			<div file-box="true" class="form-control-content" data-temp-obj="<?=rows[i].name?>"
				data-temp-title="<?=rows[i].title?>" data-type-tag="uploadFile">
				<label file-btn="true" onclick="addUploadFileNew(this);" for="uploadFileInputNew" class="btn btn-warning">选择文件</label>
				<input file-input="true" name="<?=rows[i].name?>" class="clean" type="hidden"> 
				<span file-msg="true" class="fx1"></span>
				<a file-a="true" href="#" target="_bank"></a>
			</div>
		</td>
		</tr>
   <?}?>
	</tbody>
</table>
</script>


